New Content for Existing Code and Styles

As mentioned previously, when the iframe is loaded its content is transferred to a display div. The styles of the iframed document are not transferred. Styles in the document containing the iframe apply to the transferred content.

Since the content from the iframe is incorporated into the main document, links will by default load the new URL into the main window. A target attribute can be included in links specifying the name of the hidden iframe to load the new content there instead:

<a href="code.html" target="buffer" 
    onclick="return dw_Loader.load(this.href)">The JavaScript</a>

Function calls to load the iframe can be set up unobtrusively instead of being included in links if you prefer. This example does so. See in the head of the main document.

Script segments or JavaScript files included in the iframed document are not transferred. But JavaScript can be applied to the content before the transfer. Onload events in iframe documents are invoked before the onload event of the iframe element they are contained in. Also, a callback can be included in the iframe element's call to display onload.

See more information about all this in The JavaScript.