Results 1 to 4 of 4

Thread: Java Script - Script compatibility.

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4

    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.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2003
    Posts
    4
    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?

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    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
  •  



Click Here to Expand Forum to Full Width