简体   繁体   中英

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").

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) ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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