简体   繁体   中英

CRM Dynamics 2015 IFrame Communication

I have a web resource that I am calling inside of a dialog.

It seems that in a recent update of CRM Dynamics, they are now overwriting the window.frames object, which I used to get a list of all iframes before.

Here is a view of the frames object in the console..

在此处输入图片说明

Does anyone know how do I get access to the available iframes on the page?

Previous code that used to work...

 var found = false;
 $.each(parent.window.frames, function (i, val) {
        if (!found) {
            if (parent.window.frames[i].Xrm.Page.data != null) {
                console.log("got here, page data not null");
                found = true;
            }
        }
    });

Version of Dynamics: 7.0.2.53

You may try to get all IFrame controls using the following code:

var iframeControlArray = Xrm.Page.getControl(function (control, index) { 
    return control.getControlType() == "iframe"; 
});

and then access the IFrame DOM Object:

var iframeDomObject = iframeControlArray[0].getObject();
var iframeDocument = iframeDomObject.contentDocument  
        || iframeDomObject.contentWindow.document; 

And if the IFrame resource in the another domain and you have a full access to to it, it would be better to make "IFrame communication across domains" using window.postMessage() . More about it here:

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