document.body is a viewport when IE is in Quirks mode. If the document inside your iframe is in Quirks, the scrollHeight body will be equal to the height of its viewport, i.e. default height iframe.
If you really need to get the height of the document in Quirks mode, you will need to add an extra wrapper div to measure. It is much better to fix this to make sure all of your documents use the standards regime doctrine. You should not create anything with Quirks mode in this decade.
In addition, you should not use document.all for IE sniffing (this may go wrong for other browsers that support it), you should not use iframe.document (it is non-standard and not even documented by MSDN) and you should always add 'px' units (IE can handle this well, and you need it in standard mode).
function change_height(iframe) { var doc= 'contentDocument' in iframe? iframe.contentDocument : iframe.contentWindow.document; iframe.style.height= doc.body.offsetHeight+'px'; }
bobince Apr 21 '10 at 17:03 2010-04-21 17:03
source share