问题
please find below the code where I am trying to access a Webresource. I am working on CRM 2016
var xyz= window.xyz|| {};
$("#WebResource").contentWindow.xyz.Scheduler.load();
Gives out "Unable to get property 'contentWindow' of undefined or null reference" message.
Need help.
回答1:
Don't manipulate the DOM, it's unsupported.
Do this
Xrm.Page.getControl("WebResource").getObject().contentWindow.[etc. etc.]
回答2:
As already pointed out; manipulating the DOM directly is unsupported. However, if you're doing this purely for debugging purposes from the F12 console you can prepend your calls to the Xrm object as follows:
var webResource = frames[0].Xrm.Page.getControl("WebResource_Name");
var content = webResource.getObject().contentWindow.document;
Note that the specific frame containing the form does move around sometimes depending on which form you're looking at so if frames[0] doesn't work, try frames[1] instead.
来源:https://stackoverflow.com/questions/40220751/contentwindow-iframe-crm-2016