I am struggling with the issue that I am unable to attach any onload function to my dynamically created iframe. This happens only in IE, works in FF. Here is my code:
var ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "legacy-hostpage.html?rnd=" + new Date().getTime());
ifrm.style.width = "100%";
ifrm.style.height = "400px";
ifrm.name = "legacy-frame";
ifrm.id = "IFRM-" + new Date().getTime();
ifrm.onload = function() {
alert('onload onload');
};
wrapper.appendChild(ifrm);
I wish I could use jQuery in this project but I can’t.. Can you tell me what’s wrong?
I think you should use attachEvent function for IE.
Above code should work in all browsers without problems.