user160820
user160820

Reputation: 15200

iframe onload function not working in IE

function showHotelbewertung(W3CElement, objCode) {
   var iframe = document.createElement("iframe"),
       img = document.createElement("img");

       W3CElement.style.position = "relative"

       iframe.className = "bewertung_iframe"  
       iframe.id = "bewertung_iframe"  
       iframe.src = "http://example.com&code="+objCode;
       W3CElement.appendChild(iframe);  

       iframe.onload = function() {
         //var height=iframe.contentWindow.document.body.scrollHeight;
         alert('')
         W3CElement.removeChild(img);
         iframe.style.cssText = "width:100%;height:400px";
       }

       img.src = "assets/images/loader.gif";
       img.style.cssText = "position:absolute;top:15px;left:300px";
       W3CElement.appendChild(img);
}

it works fine in FF but iframe.onload does not in IE.

Upvotes: 0

Views: 972

Answers (2)

michaeljiz
michaeljiz

Reputation: 194

frame.attachEvent('onload', function() { CustomFunction()});

Upvotes: 0

Have you ever been tried some thing like this?

setTimeout(function() {
       iframe.onload = function() {
         //var height=iframe.contentWindow.document.body.scrollHeight;
         alert('');
         W3CElement.removeChild(img);
         iframe.style.cssText = "width:100%;height:400px";
       }
}, 0);

Upvotes: 1

Related Questions