2

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?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Tim Partridge
  • 3,365
  • 1
  • 42
  • 52

1 Answers1

1

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

Community
  • 1
  • 1
Marco Medrano
  • 2,530
  • 1
  • 21
  • 35