Results 1 to 4 of 4

Thread: Resizing an iframe everytime a new page is loaded.

  1. #1
    Join Date
    Apr 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Resizing an iframe everytime a new page is loaded.

    HI there. I am looking to try and figure out how to change the height of an iframe everytime a new page is loaded inside of it. I currently can change it onLoad of the initial iframe but not after something else is loaded inside of it. Here is what I currently have

    Code:
    <script language="JavaScript">
    <!--
    function calcHeight()
    {
      //find the height of the internal page
      var the_height=
        document.getElementById('iframe').contentWindow.
          document.body.scrollHeight;
    
      //change the height of the iframe
      document.getElementById('iframe').height=
          the_height;
    	  
    }
    //-->
    </script>
    Then the actual iframe

    Code:
    <iframe onLoad="calcHeight();" width="600" id="iframe" src="somepage.php" scrolling="NO" frameborder="0" height="100">An iframe capable browser is required to view this web site.</iframe>
    Any help would be great. Thank you.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I don't think you can. I don't believe there's a handler associated with iframes for this eventuality. You'd just have to add the code to wherever the iframe-changing code is called from.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It is not considered W3C valid but, the three major browsers like it fine. See my "Iframe SSI script III" as first introduced here and later modified for better behavior under Opera here. If you want a page that will validate, consider using DD's Iframe SSI script II or wait for my next modification in which the onload event(s) will be added dynamically to the iframe(s), so as not to excite the W3C validator.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Apr 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    works in firefox so it works for me. thank you.

Bookmarks

Posting Permissions

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