|
-
Nov 13th, 2003, 09:45 AM
#1
Thread Starter
New Member
Java Script - Script compatibility.
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.
Code:
<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.
-
Nov 13th, 2003, 10:07 AM
#2
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Nov 13th, 2003, 10:12 AM
#3
Thread Starter
New Member
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?
-
Nov 16th, 2003, 07:54 AM
#4
Frenzied Member
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()")
Have I helped you? Please Rate my posts. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|