Dynamic iframe height

I am currently working on an existing site using iframes (sigh!), Which is very difficult for me to work with, and I am having problems increasing the height of the iframe with the height of the HTML content.

I tried several different script fragments that float around in interwebs, but none of them worked for me. I really want to use jQuery for this, but this is not an option, because IT wants to keep the pageload size.

Does anyone know of a good way to do this, in a way that works with both FF and IE 6+?

+6
javascript html iframe
source share
1 answer

You just have to simply specify the height and width parameters - since they are valid attributes of the iframe dom element.

function resize(width, height) { var frame = document.getElementById('my_iframe'); frame.width = width; frame.height = height; } 

Of course, this only applies if you are trying to resize the iframe from its parent element (a document with the actual iframe tag). If you are trying to resize an iframe from an iframe (the document loads an iframe), you will need to call the parent function's public function to perform the resize.

In iframe: parent.resize(600, 800);

+4
source share

All Articles