Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Iframe height bug in IE  (Read 26285 times)

0 Members and 1 Guest are viewing this topic.

Hunter484

    Topic Starter


    Rookie

  • I soar free.
  • Thanked: 2
    Iframe height bug in IE
    « on: January 21, 2009, 08:51:15 PM »
    Does anyone know how to get Internet Explorer to render an Iframe's "height" attribute correctly, or is this an inherent (stupid) bug in the browser?

    If you use "height=100%" (or any percentage), IE shrinks the Iframe to only a few lines tall, and centers it in the area set aside for it.  Oddly, the width attribute works normally, but not the height.  IE is the only browser I've seen that has this problem.

    I've got a workaround in place by assigning a specific height, in pixels, to the Iframe, but I'd like make it adapt to the size of the viewer's browser window.

    Just wondering if it's possible...
      

    soybean



      Genius
    • The first soybean ever to learn the computer.
    • Thanked: 469
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Iframe height bug in IE
    « Reply #1 on: January 22, 2009, 06:44:33 AM »

    kpac

    • Web moderator
    • Moderator


    • Hacker

    • kpac®
    • Thanked: 184
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 7
    Re: Iframe height bug in IE
    « Reply #2 on: January 23, 2009, 02:18:21 PM »
    What you could do is display the iframe in a table, and set the height and width of the table, then set the height and width of the iframe to "auto".

    Hunter484

      Topic Starter


      Rookie

    • I soar free.
    • Thanked: 2
      Re: Iframe height bug in IE
      « Reply #3 on: January 24, 2009, 03:00:31 PM »
      Does this help?: http://htmlhelp.com/reference/html40/special/iframe.html
      Not really.  I already know how to adjust height and width using pixel values or percentages.  Good tutorial though.  :)


      What you could do is display the iframe in a table, and set the height and width of the table, then set the height and width of the iframe to "auto".
      Sorry, that's a step in the wrong direction.  Apparently "auto" isn't an acceptable value for those attributes.  Entering them shrinks the Iframe to about 300x200 pixels on IE and Firefox.

      I already have the Iframe embedded in a cell of a table.  I'm just wondering why, when you enter something like 100% for the height and width, IE stretches the Iframe's width to fill the available space, but keeps the height at about 300 pixels.  Other browsers stretch both dimensions as you'd expect, but not IE.  It's very odd...
        

      kpac

      • Web moderator
      • Moderator


      • Hacker

      • kpac®
      • Thanked: 184
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 7

      Hunter484

        Topic Starter


        Rookie

      • I soar free.
      • Thanked: 2
        Re: Iframe height bug in IE
        « Reply #5 on: January 25, 2009, 08:59:16 PM »
        http://virtuelvis.com/archives/2004/02/msie-is-the-problem
        This one doesn't apply.  I'm not using Iframe to trick anyone into installing anything.  I'm using it to display ordinary pages from the same web site, while a nice menu is available outside the Iframe for visitors to navigate the website's contents with.


        http://www.dynamicdrive.com/forums/archive/index.php/t-5277.html
        This one is really close to the issue.  We both have an Iframe inside a table that doesn't automatically expand vertically to fill the space it is assigned.

        There's only one difference: this guys didn't assign a height attribute to the table cell that contains his Iframe.  I gave mine a height of 100%.

        It seems that the Iframe only expands vertically under two conditions: when I enter a pixel value into the Iframe's height; or when I set the Ifram to 100% tall and give the table cell a pixel value for the height.  Omitting either one, or setting both to "100%" results in IE shrinking the Iframe to only about 200 pixels high.  I thought that if it works for width, it would work for height too...but I guess IE treats the two differently (and less intelligently) then other browsers.  :-\

        Stupid IE...  Thanks anyway.  That link helped a lot to explain what is going on.  Apparently, what I want to do is simply not possible with IE.
          

        kpac

        • Web moderator
        • Moderator


        • Hacker

        • kpac®
        • Thanked: 184
          • Yes
          • Yes
          • Yes
        • Certifications: List
        • Computer: Specs
        • Experience: Expert
        • OS: Windows 7
        Re: Iframe height bug in IE
        « Reply #6 on: January 26, 2009, 07:38:53 AM »
        You could try setting it with JavaScript.

        Code: [Select]
        <script type="text/javascript">
        function iframeHeight()
        {
          document.getElementById('iframe').height="100%";
        }
        </script>

        The above obviously goes into the <head>, and add this to the <body>

        Code: [Select]
        <body onload="iframeHeight()">
          <iframe height="100px" id="iframe" src=".../frame.htm"></iframe>
        </body>

        Does that work?

        Hunter484

          Topic Starter


          Rookie

        • I soar free.
        • Thanked: 2
          Re: Iframe height bug in IE
          « Reply #7 on: January 28, 2009, 05:31:16 PM »
          Nope.