Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: iframe script

  1. #1
    New Coder
    Join Date
    Jan 2003
    Location
    NC, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    iframe script

    I need some help with an iframe. I am trying to make a script that changes the height of the iframe to the height of the page within the iframe whenever the page is loaded into it, with no success.
    Every page that loads into the iframe has a body onload....


    <script language="Javascript" type="text/javascript">
    <!--
    var content_box = parent.document.getElementbyId("iframe")
    -->
    </script>
    </head>
    <body onload="resize_content()"


    Now i just need another part of the script that resizes the iframe to the height of the page in the iframe. Any help is greatly appreciated.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following.




    Place the script in the page loaded into the Iframe


    <script>
    function test(){
    H=document.body.scrollHeight
    W=document.body.scrollWidth
    parent.document.getElementById("frame1").height=H
    parent.document.getElementById("frame1").width=W
    }
    </script>

    Include

    onload="test()"

    in the opening BODY tag

  • #3
    New Coder
    Join Date
    Jan 2003
    Location
    NC, USA
    Posts
    49
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thanks

    Thats all I needed.
    The scrollHeight was the key. thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •