Zend - The PHP Company




HTML

Add Code


Changing Two FRAMEs At Once  

Type: code fragment
Added by: rlynch
Entered: 13/05/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 10265
Example of changing two frames at once.


How do I get two FRAMEs to change at once?

You could try to do it with a JavaScript hack, but that tends to not work too well.

Your other option is to actually have the links point back to the outer FRAMESET URL with TARGET="_top", and then pass down any info needed to plug in the correct content.

This does reload the left-hand frame, which may be counter to your reason for using FRAMES, but if you are only using FRAMES as a layout mechanism rather than saving on reload/performance for the navigation frame, it works just fine.

Sample:

main.php3
<?php
   
if (!isset($page)){
     
$page 'default.htm';
   }
?>
<HTML>
   <FRAMESET ...>
     <FRAME SRC=navigation.php3 ...>
     <FRAME SRC=<?php echo $page;?> ...>
   </FRAMESET>
</HTML>

navigation.php3
<HTML><BODY>
   <A HREF=main.php3?page=content1.htm TARGET="_top">link1</A>
   <A HREF=main.php3?page=content2.htm TARGET="_top">link2</A>
</BODY></HTML>

default.htm
<HTML><BODY>
   Click on a link on the left.
</BODY></HTML>

content1.htm
<HTML><BODY>
   Page 1
</BODY></HTML>

content2.htm
<HTML><BODY>
   Page 2
</BODY></HTML>


Usage Example




Rate This Script





Search



This Category All Categories