Set IFRAME src to form load avoiding load

I am considering using an IFRAME on a form and would like to know what is the correct way to avoid the traditional IFRAME mailing problem.

I thought I could just set the IFRAME src

with a call inside the form handler OnLoad

, since ( source )

The load event is fired at the end of the document loading process. At this point, all objects in the document are in the DOM, and all images, scripts, links and subframes have finished loading.

but MSDN says (in bold):

Avoid using the OnLoad event. Loading IFRAMES and web resources is asynchronous and the frame may not have finished loading until the onload script event finishes. This can cause the src property of the IFRAME or web resource that you modified to overwrite the default value for the URL property of the IFRAME or web resource.

If so, what's the correct way to set the IFRAME src

?

Note. I was thinking about using the IFRAME OnReadyStateComplete event, that is: having an event handler in the form of a script, set src

when the event fires and use a flag to indicate that it was set (for me to win 'enter an infinite load loop), but it looks like bypass.

+3


source to share


1 answer


I have no problem with the SetSrc function, I am using the Form OnLoad event.

Sample code example



// Get MAT IFrame control
var MATRepiFrame = Xrm.Page.ui.controls.get("IFRAME_MATGraph");
//Setup the URL
MATTargetUrl = serverUrl + '/crmreports/viewer/viewer.aspx?action=run&context=records&id=%7b092E3880-8266-E711-80DD-005056BD212E%7d&recordstype=1&records=' + accountId;
//Set the source
MATRepiFrame.setSrc(MATTargetUrl);

      

See webpage here for details: https://msdn.microsoft.com/en-us/library/gg328034.aspx

+1


source







All Articles