如何从动态 CRM 表单 2016 访问 <div> 元素/DOM 对象

How to access the <div> element / DOM object from the dynamics CRM form 2016

我需要更改 CRM dynamics 2016 中 CRM 表单通知元素的背景颜色以供试用。我知道它不受支持,但这是供最终用户试用的。 div元素详情如下-

<div class="Notifications Notifications-strict Notifications-strict-bottom" id="crmNotifications" style="height:; display: block;" size="3" maxheight="51">

我试过使用 window.parent.getElementById('crmNotifications').style.backgroundColor;

但运气不好。我还听说无法从实体表单访问 DOM 元素。有什么办法可以改变背景颜色吗

document.getElementById("crmNotifications").style.backgroundColor = "blue"

您需要创建一个 HTML 网络资源,将其添加到表单并使用 window.parent 访问 DOM。

例如:

<html>
 <head>
  <script>
    window.parent.document.getElementById("crmNotifications").style.backgroundColor = "blue"
  </script>
 </head>
 <body>
 </body>
</html>