OnReadyStateComplete does not start
I am trying to add a Javascript CRM web resource and I am trying to manipulate iframes, but the OnReadyStateComplete iframe event is not firing. Below, the first warning works, but the second doesn't.
function hello()
{
var audioPath= Xrm.Page.data.entity.attributes.get("new_audiopath").getValue();
//var myAudio = document.createElement('audio');
//myAudio.setAttribute('src', audioPath);
// myAudio.play();
var IFrame = Xrm.Page.ui.controls.get("IFRAME_Play");
alert(audioPath);
//var myAudio =Xrm.Page.ui.controls.get("audioSource");
IFrame.OnReadyStateComplete=function(){
alert('iframe ready');
}
}
source to share
The IFrame control has no property or event OnReadyStateComplete
. The SDK documentation only points to the menu item available in the form designer.
However, it is actually possible to attach a function to the onload
IFrame event in a supported way:
var iFrameElement = Xrm.Page.getControl("IFRAME_Play").getObject();
iFrameElement.addEventListener("load", function() {
alert("IFrame Play loaded!");
}
The function getObject
returns an IFrame object that gives you access to the iFrame and the document contained in its properties contentWindow
and contentDocument
. (See also HTML DOM IFrame Object .)
source to share