Updating two frames at a time

JavaScript FAQ | JavaScript Frames FAQ  

Question: Can I update two (or more) frames simultaneously?

Answer: Yes. The easiest way to update several frames simultaneously is to have a JavaScript function that loads a new page into each of the frames to be updated.

For example, suppose you have two frames, left and right, defined in a

FRAMESET
like this:
<FRAMESET cols="200,*" border=3 frameborder=yes framespacing=2 >
  <FRAME SRC="leftpage.htm" NAME="left">
  <FRAME SRC="rightpage.htm" NAME="right">
</FRAMESET>
Then a function for updating both frames might look like this:
function updateBothFrames() {
 top.left.location="newpage1.htm";
 top.right.location="newpage2.htm";
}
This function can be called when the user presses a button or clicks a hyperlink.
The following examples show the HTML code for a button and hyperlink that invoke the function:
<a href=#
   onclick="updateBothFrames();return false;"
>Click here</a>

<input type=button 
       value="Press me" 
       onclick="updateBothFrames();"
>

Copyright © 1996-2018, JavascriptFAQ.net.