iframe.document.body.scrollHeight is double the correct value
Posted
by Dean J
on Stack Overflow
See other posts from Stack Overflow
or by Dean J
Published on 2010-04-21T16:21:06Z
Indexed on
2010/04/21
16:23 UTC
Read the original article
Hit count: 397
<iframe name="asdf" id="asdf" onload="change_height(this)" src="asdf.jsp" width="250" scrolling="no" frameborder="0"></iframe>
function change_height(iframe) {
if (document.all) {
// IE.
ieheight = iframe.document.body.scrollHeight;
iframe.style.height = ieheight;
} else {
// Firefox.
ffheight= iframe.contentDocument.body.offsetHeight;
iframe.style.height = ffheight+ 'px';
}
}
ieheight is twice the actual height when this runs in IE7; haven't tested on IE6. It's the same value if I use scrollHeight or offsetHeight.
It's the correct height in Firefox.
Before I patch this by just dividing the IE value /2, what's the right way to do this?
© Stack Overflow or respective owner