1.

Solve : Iframe height bug in IE?

Answer»

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...Does this help?: http://htmlhelp.com/reference/html40/special/iframe.htmlWhat 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".Quote from: soybean on January 22, 2009, 06:44:33 AM

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.


Quote from: kpac 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".
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...Maybe these links can help you...

http://virtuelvis.com/archives/2004/02/msie-is-the-problem
http://www.dynamicdrive.com/forums/archive/index.php/t-5277.htmlQuote from: kpac on January 25, 2009, 03:39:38 AM
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.


Quote from: kpac on January 25, 2009, 03:39:38 AM
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.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 , and add this to the

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

Does that work?Nope.


Discussion

No Comment Found