How can I change two or more pages when a link is clicked?
When you use frames to create a page layout and you want to update the contents
of more then one of the frames, a normal link won't work. There are two
solutions to this problem.
1. Load a new page that contains a new FRAMESET
Replacing a FRAMESET page with a new one can update more then one page. The
disadvantage is that you must create a separate FRAMESET page for each possible
combination of frame contents.
2. Load the pages using JavaScript
More practical is to use a script to load the new pages. This involves two
changes, adding a script to the page where the links are in, and changing the
links so that the script is used.
First the script:
 |
<SCRIPT language="javascript">
function loadLinks(cUrl1,cFrame1,cUrl2,cFrame2) {
parent.frames[cFrame1].location = cUrl1
parent.frames[cFrame2].location = cUrl2
}
</SCRIPT>
|
You must place this script in the HEAD section of the page. The script will
load two pages in two frames you have defined in a
FRAMESET.
Now you must change the links so that this script is used to load the links.
 |
<A href="javascript:loadLinks('url1','frame1','url2','frame2')">Load two pages</A>
|
You must replace the values url1
, frame1
,
url2
and frame2
with the appropriate ones on your site.
For example, lets say that you have two frames, one called
menubar and the other called textbody. The
following link will load the file mainmenu.html in the menubar
frame, and history.html in the textbody frame:
 |
<A href="javascript:loadLinks('mainmenu.html','menubar','history.html','textbody')">Load two pages</A>
|
Note
This script has a restriction, because it expects the frames that you want to
update, are all laid out in the same FRAMESET page. If you have a more complex
page layout, using nested pages with FRAMESET's, then the script must be
modified.
You must change the references to the frame, so that they reflect the structure
of how the frames have been defined. These are the parts
parent.frames[cFrame1]
and parent.frames[cFrame2]
.
Back to the FAQ main page
Copyright © 1996 - 2000 Rob Schlüter,
schluter@knoware.nl
(last updated 1999/03/01)