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 to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto resize iframe height

    Hi guys,
    I've been stucking in this problem for months and couldn't find the solution yet. My index.php contains a header (php require) and an iframe so as to display the content. But when the content of the iframe is too long, it's naturally display a scrollbar beside that iframe, and it looks not nice. Now, i want the height of the iframe to be resized automatically, so, I think, the iframe's scrollbar will disappear and the overall scrollbar (I mean the scrollbar of the whole page, not just an iframe) will appear. That looks like AJAX. Thanks for helping.

  • #2
    New Coder
    Join Date
    May 2009
    Location
    LA, USA
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Same Issue

    I have the same challenge and not found a solution yet! Maybe there isn't one.


  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this. It works on my IE7 and FF. Please note that the called source must be the same domain. If you use your localhost server to call a remote site then it won't work.
    <head>
    ...
    <script type= "text/javascript">
    window.onload = function() {
    var newHeight = document.getElementById('glue').contentWindow.document.body.scrollHeight;
    document.getElementById('glue').style.height = newHeight+10+"px";
    }
    </script>
    ...
    </head>

    <body>
    ...
    <iframe id="glue" width="100%" src="http://huyenlam.com"></iframe>
    ...
    </body>
    Last edited by lamnvo; 06-04-2009 at 01:53 AM.


  •  

    Posting Permissions

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