PDA

View Full Version : scrollHeight/offsetHeight (Firefox/IE) Iframes



rs131
04 Sep 2006, 09:34 AM
I found a problem in javascript between IE and Firefox when trying to adjust the height of iframes depending on the content but I don't know how to fix it. Obviously IE doesn't work with offsetHeight because when I change the document.body.scrollHeight; to document.body.offsetHeight; the iframes resize in the content in Firefox but do not resize in IE. When I use document.body.scrollHeight; Internet Explorer will resize the iframes but Firefox will not. I do not understand why this is? scrollHeight (IE), offsetHeight(Firefox)... WIERD - Anyone know a solution here's the code:




<script type="text/javascript">
function autofitIframe(id)
{
var the_height=
parent.document.getElementById(id).contentWindow.document.body.scrollHeight;

//change the height of the iframe
parent.document.getElementById(id).height=the_height;
}

Rambo Tribble
06 Sep 2006, 09:44 PM
Try document.body.parentNode.clientHeight.