Help Desk
By Jeff Keller, Guest Editor
One Link, Many Frames
Dear Help Desk,
Is there a way to load two different frames with one hyperlink?
- Joe
Dear Joe,
There is indeed, though you'll have to write a little JavaScript to do so. Before you do that, be sure to note the names of the frames that you want to change. For this example, let's say that your page has three horizontal framesınamed "top," "middle," and "bottom". Assume that when you click on a link in the top frame, you want new data to load into the middle and bottom frames.
You'll need to insert this JavaScript code in the <HEAD> section of the HTML file that has your link:
<script language="javascript">
function loadLinks
(URL1, Frame1, URL2, Frame2) {
parent.frames[Frame1]
.location = URL1
parent.frames[Frame2]
.location = URL2
}
</script>
This script will load the URL1 file (or URL) into the frame you designate as Frame1. Then URL2 will load into the frame designated as Frame2.
Finally, you need to call this script from the link in question, like so:
<a href="http://www.newarchitectmag.com/documents/s=5197/new1013637358/javascript:loadLinks(
'newmiddle.html','middle',
'newbottom.html','bottom'
">Click Here!</a>
Make sure you place the JavaScript in the HTML file where you want the navigation to take place. In this case, it would be placed in the same file as the "Click Here!" link. Keep in mind that this method works only when the frames are in the same frameset.