PDA

Click to See Complete Forum and Search --> : Java Script - Script compatibility.


bassplayinuk
Nov 13th, 2003, 08:45 AM
I use the followinf script to resize the an iframe depending on the scroll size of the page within the frame. Saves having another scroll bar on the page.


<script language="javascript">
function checkiFrame()
{ if ((document.all('imain').readyState=="complete"))
{
if (document.frames('imain',0).document.body.scrollHeight > 500)
{ document.all('imain').style.height = document.frames('imain',0).document.body.scrollHeight;}
else
{ document.all('imain').style.height = 500;}
}
}
</script>


Problem is, it doesn't work in Netscape and Opera. Just Internet Explorer.

Anyone know what's wrong? I don't tend to use Java Script that much so I haven't got a clue.

CornedBee
Nov 13th, 2003, 09:07 AM
Don't use document.all, use document.getElementByID and make sure the iframe really has an id attribute, not only name.

And I believe no browser except IE has the readyState attribute. You should instead set an onload event on the iframe's content that calls a function in the parent.

bassplayinuk
Nov 13th, 2003, 09:12 AM
Originally posted by CornedBee
And I believe no browser except IE has the readyState attribute. You should instead set an onload event on the iframe's content that calls a function in the parent.

Cheers. Any ideas on how to go about this?

Acidic
Nov 16th, 2003, 06:54 AM
Cheers. Any ideas on how to go about this?

instead of:
all('imain')
use
getElementById('imain')

and instead of:
if ((document.all('imain').readyState=="complete"))
but this is the body tag:
onLoad="checkiFrame()")