PDA

View Full Version : Javascript iFrame height issue?



nateweller
04-06-2011, 10:09 PM
I have an HTML page with an iframe - but it's source is always changing height. So I need to script the iframe so that it calculates the height of the source, and then adjusts the iframe to that height.

Right now I am trying to use this code:

(this is the header)

<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;

//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>

(this on the iframe)

<iframe src="whatever.html" id="the_iframe" onLoad="calcHeight();" height="1" scrolling="no" frameborder="no" width="900px"></iframe>


The problem is, it works great locally on my computer, and in Dreamweaver - but when I upload it to my server it just wont work? What am I doing wrong?