Forum Moderators: open

Message Too Old, No Replies

iframe script works great in explorer but not in firefox

iframe,auto height,explorer,firefox

         

rickymartin

6:51 pm on Jun 20, 2008 (gmt 0)

10+ Year Member



hi there!

im new here. so hello everyone!

i have a problem. and was wondering if anyone can help me. i have this awesome script which is so imple but works fantastic. It tells an iframe to load in an htm page but changes to whatever hieght the htm page is. its great for people who do not want to have a scroll bar in the iframe and just want the browser scroll bar.

the problem is that the script works in exploere only and not firefox. i read in here a big explanation of the difference between firefox and explorer but its way over my head. if i give you the code would any of you be able to figure out what needs to be changed in the script so it deos work?

here is the script located right after the header:

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

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

then in the iframe the script is (the only part below that communicates with the script above is onLoad="calcHeight();":

<td height="194" colspan="4" valign="top" bgcolor="#FFFFFF"><iframe name="content" style="border:0px" width=923 onLoad="calcHeight();" src="home.htm" scrolling="NO" frameborder="0" height="0"> </iframe></td>

thank you so much for helping me out. its very very much appreciated.

daveVk

3:03 am on Jun 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try

document.getElementById('content').contentWindow.
documentElement.scrollHeight;

in place of

document.getElementById('content').contentWindow.
document.body.scrollHeight;

rickymartin

12:01 pm on Jun 21, 2008 (gmt 0)

10+ Year Member



i tried it but it didnt work. matter of fact if didnt work in either firefox or explorer.....any other ideas?

Brandon

rickymartin

11:14 pm on Jun 25, 2008 (gmt 0)

10+ Year Member



hmmmm i tried changing the:

iframe name="content"
to
id="content"

and now firfox and explorer both show the home.htm page load but when i click other buttons they don't load up. is there anything im missing?

rickymartin

11:23 pm on Jun 25, 2008 (gmt 0)

10+ Year Member



just figured it out. <iframe name="content" id="content" i put both of these on and it worked...i cant belive it was that simple!