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
    Jun 2002
    Location
    Maputo, Mozambique
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Iframe height mach content height

    Hallo, people!
    It is possible to set the height of an iframe depending on the height of the content?
    I mean, if the page included contain a few text the iframe has to be small, but if the text is a lot the iframe height should grow to show all the content without scrollbar.

    Any suggestion?

    thanks

    Alex
    "COGITO, ERGO SUM"

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts

    *bump*

    I've seen it done somewhere... I think it was just with FRAMEs, not iFRAMEs, though.

    I'll see if I can find it again.

    Quíet Storm Designs ~ Art is not what you see, but what you make others see.
    · the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    <html>
    <head>
    <title>untitled</title>
    <script type="text/javascript" language="javascript">

    var oldHTML = '<html><head><title>untitled</title></head><body><h2>original</h2></body></html>';
    var newHTML = '<html><head><title>untitled</title></head><body>';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah ';
    newHTML += 'blah blah blah blah blah blah</body></html>';

    function sizeit() {
    var dWid = frames['IF'].document.body.scrollWidth;
    var dHgt = frames['IF'].document.body.scrollHeight;
    frames['IF'].resizeTo(dWid,dHgt);
    }

    </script>
    </head>
    <body>
    <iframe id="IF" onload="sizeit()" scrolling="no" src="javascript&#58;parent.oldHTML"></iframe>
    <br><br>
    <a href="javascript&#58;document.getElementById('IF').src='javascript&#58;parent.newHTML';void(0)">
    NEW</a>
    </body>
    </html>


  •  

    Posting Permissions

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