Loading New Documents into Iframes
You can load new documents into the iframe either by specifying a target attribute in the link or through the use of JavaScript. This link specifies the iframe's name in the target attribute and will load Google into the iframe below:
<a href="http://www.google.com" target="ifrm">link</a>
The two rows of links below demonstrate the two methods for loading new documents using JavaScript. Click a Page 2 link in either row for more information.
These links use the frames array to obtain the reference and change its location property.
These links change the src
property of the iframe obtained via document.getElementById
.
You can use your browser's menu commands to view the source code of this document. You can right-click on an iframe to access the source code of the document contained inside it. This tutorial's examples are available for download in a zipped file.
Back to Iframes Tutorial