Setting Iframe Height to Match Content Height
HTML5 introduces a seamless iframe attribute which is not yet supported in a meaningful way by any browsers. This code, as well as the Hidden Iframe code, provides some of the features that will be provided by the seamless attribute once it is supported.
Links in the document inside the iframe open inside the iframe by default, but you can include target attributes to point to the parent document as described in Loading New Documents in Iframes.
The styles in the parent document are not inherited by the iframe's document. Styles to be applied to the content in an iframe need to be included in that document.
getDocHeight function obtains the height of the document, cross-browser for both standards and quirks mode documents. The
setIframeHeight function sets the iframe element's height to match the contained document's height.
A call to the function
setIframeHeight is added to the iframe element's onload attribute:
<iframe id="ifrm" src="pages/height1.html" onload="setIframeHeight(this.id)"></iframe>