2012-06-01

Resize an iframe according to the content height

Here is how you can resize the iframe height dynamically according to the web page height which is loaded inside the iframe.

Place the following method within the web page which contains the iframe

function resizeiFrame(newHeight)
{
    var Tab1_ = document.getElementById('frame');
    Tab1_.height = newHeight;
}

And on the page, which you wish to load inside the iframe, add the below method so it will call the above method

<body onload="parent.resizeiFrame(document.body.scrollHeight)">

No comments: