简体   繁体   English

Dynamics CRM动态获取HTML Webresource父控件

[英]Dynamics CRM Dynamically getting HTML webresource parent control

We have an embedded HTML web resource on a form with the name property of the control("WebResource_MyWebResource"). 我们在具有控件的name属性的表单上具有嵌入式HTML Web资源(“ WebResource_MyWebResource”)。

Is there a method we can use from within the HTML web resource that allows us to dynamically get the name property of it's own parent control, or will we need to pass in the webresource control name as a data parameter to use it within the script via parent.Xrm.Page.getControl(arg) ? 是否可以在HTML Web资源中使用一种方法,使我们能够动态获取其自身父控件的name属性,还是需要将webresource控件名称作为数据参数传递,以便通过以下方式在脚本中使用它: parent.Xrm.Page.getControl(arg)吗?

We don't want to hard code the resource name as it's for generic functionality and won't necessarily know the name the end user will give to the control. 我们不想为通用功能硬编码资源名称,也不必知道最终用户将为控件指定的名称。

I had always wanted an easy way to get this myself and finally put the time in a while back to figure it out: 我一直想要一种简单的方法来解决这个问题,并最终花点时间来解决:

var win = document.defaultView || document.parentWindow; /* parentWindow for IE8- */
var parentIframeId = win.frameElement.id; 

The above code when executed from your web resource will get you id of the iframe element which contains the web resource. 从您的网络资源执行上述代码后,您将获得包含该网络资源的iframe元素的ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM