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?