Iframe auto-height not working when page changes in IE
Posted
by DisgruntledGoat
on Stack Overflow
See other posts from Stack Overflow
or by DisgruntledGoat
Published on 2010-04-14T11:12:44Z
Indexed on
2010/04/14
11:23 UTC
Read the original article
Hit count: 232
I have an iframe in a page, with the following auto-height script.
function autoHeight(e)
{
if ( e.contentDocument ) {
e.height = e.contentDocument.body.offsetHeight + 35;
}
else {
e.height = e.contentWindow.document.body.scrollHeight + 35;
}
}
document.domain = "totalstudents.co.uk";
var ifr = document.getElementById('housingdata');
ifr.onload = function() {
autoHeight(ifr);
}
The iframe resizes fine when the outer page is loaded, but when I go to a new page in the iframe, scrollbars appear and the page does not get resized in Internet Explorer. In other browsers the iframe gets resized, because the onload event fires each time.
I'm using IE8 but the outer page is setting it to IE7 compatibility mode. Is there a workaround for IE?
© Stack Overflow or respective owner