This is how DD did it in his iframe SSI II script (crucial parts red):
Code:
function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}
The easiest way is to use an onload event on the page(s) being loaded into the iframe.
This also works but is invalid according to the w3c:
<iframe onload="doSomething();"></iframe>
And since DD's method from above uses the iframe as element (as opposed to the iframe as named window), this might work:
Code:
document.getElementById('iframeId').onload=doSomething;
Note, when using onload in code, the function called cannot accept either parameters or the parameter parenthesis. You can use a function though:
Code:
document.getElementById('iframeId').onload=function(){doSomething('blue', 32);}
Bookmarks