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
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post

    Auto fit iframe to content

    Hi All,

    I am working on site where I am using iframes for dynamic html files.
    Each html file having own length and my iframe height is fixed.

    How can I set auto height for each page coming in iframe?


    - Jits
    globtier.com
    jits
    Web 2.0 Expert

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Give this a try

    PHP Code:
    <script type="text/javascript">
    <!--

    moz=document.getElementById&&!document.all
    mozHeightOffset
    =20

    function resize_iframe(){
    document.getElementById("iframe_id").height=100 // default heightdocument.getElementById('iframe_id').height=window.frames["iframe_name"].document.body.scrollHeight+(moz?mozHeightOffset:0)
    }
    // -->
    </script>

    <iframe width=300 id="iframe_id" name="iframe_name" src="" scrolling="no" frameborder="yes" onload=resize_iframe()></iframe> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New Coder
    Join Date
    Sep 2006
    Posts
    23
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Mr J View Post
    Give this a try

    PHP Code:
    <script type="text/javascript">
    <!--

    moz=document.getElementById&&!document.all
    mozHeightOffset
    =20

    function resize_iframe(){
    document.getElementById("iframe_id").height=100 // default heightdocument.getElementById('iframe_id').height=window.frames["iframe_name"].document.body.scrollHeight+(moz?mozHeightOffset:0)
    }
    // -->
    </script>

    <iframe width=300 id="iframe_id" name="iframe_name" src="" scrolling="no" frameborder="yes" onload=resize_iframe()></iframe> 
    I had tried this but not working properly in OPERA browser.

    Thanks
    - Jits
    jits
    Web 2.0 Expert


  •  

    Posting Permissions

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