Setting Iframe Height to Match Content Height
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. This handling of styles and links contrasts with the Hidden Iframes code and example where links open in the main window and the parent document styles are inherited by the iframe's content.
getDocHeight function that obtains the height of the document, cross-browser for both standards and quirks mode documents, and a
setIframeHeight function that 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>