2
votes

I have defined a web resource as follows:

function setIframe_OnLoad() {
    var iFrame = Xrm.Page.ui.controls.get('IFRAME_docmgmt');
    var url = iFrame.getSrc();
    if (url.indexOf("blank") != -1) {
        setiFrameUrl();
    }
}

function setiFrameUrl() {
    debugger;
    var url = 'http://www.google.com';
    Xrm.Page.getControl('IFRAME_docmgmt').setSrc(url);
}

And I have configured the url of an iframe named docmgmt to about:blank. I wired up the OnReadyStateComplete event of the iframe to the setIframe_OnLoad function. When I load my CRM 2013 form, the debugger line is hit and I can step through and see that the Xrm.Page.ui.controls.get('IFRAME_docmgmt').getSrc() value does indeed change to http://www.google.com. When the function completes, the page reloads. I don't know why. When it reloads, the iframe is set to about:blank again. Does anyone have a working code sample for setting an iFrame URL programmatically using javascript in Dynamics CRM 2013?

1
Is this all URLs? Have you tried https to avoid mixed mode?Paul Way
Good point. It's actually not mixed, both are httpTim Partridge

1 Answers

1
votes

www.google.com wont work because next error:

Refused to display 'https://www.google.com.bo/?gws_rd=cr&ei=XZKQU6_YA6HNsQTkhIKIBA' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. More references here.

So as the start page is set to about:blank this remains after .setSrc function. Actually there are many sites which does not allow use theirs webpages as iFrames.

I wrote same code that you but using http://www.bing.com and it is working pretty fine :)