http://skipsauls.blogspot.com/2008/06/web-20-performance-optimization-get-a.html
© Scott S. Nelson
I ran into some ugliness recently setting an iFrame height dynamically where the script would run away on IE. I found the answer at http://stackoverflow.com/questions/1500312/javascript-onresize-event, posted by Pim Jager. The resulting combination of the resize and his event handling is as follows:
function getDocHeight()
{
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight));
}function setIframeHeight(frameId, offset)
{
document.getElementById(frameId).height = (getDocHeight()-offset)+’px’;
}var resizeIframeTimeOut = null;
var func = function() {setIframeHeight(‘boInfoViewIframe’, 150);};
window.onresize = function(){
if(resizeIframeTimeOut != null) clearTimeout(resizeIframeTimeOut);
setTimeout(func, 100);
};setIframeHeight(‘boInfoViewIframe’, 150);
One note about resizing elements is that IE will resize again if your new size causes the document size to grow. That was a two hour lesson for me 🙂