PDA

View Full Version : can this be used for 3 frames?


perayo
05-22-2003, 05:06 PM
For a 2-framed page (index.html) like this:

<frameset cols="100,*">
<frame src="menu.html" name="menu">
<frame src="main.html" name="main">
</frameset>

I use the peices of javascript below to 'save a frame' such that when a visitor types in http://www.domain.com/main.html it will automatically load the menu along with main.html. Also works with sub-pages.

<!--Goes into index.html-->
function frame_saver(){
if (self.location.search){
self.main.location = "http://www.domain.com" + self.location.search.slice(1);}
}
self.onload = frame_saver;


<!--Goes into menu.html-->
if (self == top) {self.location = "http://www.domain.com"; }


<!--Goes into main.html (and other sub-pages)-->
if (self == top){
var url = self.location.pathname;
self.location = "http://www.domain.com/index.html?" + url;
}


Question: How can I edit it so that it works for a site with 3 frames? Like:

<frameset cols="100,*">
<frame src="menu.html" name="menu">
<frameset rows="100,*">
<frame src="main_top.html" name="main_top">
<frame src="main_bottom.html" name="main_bottom">
</frameset>
</frameset>

So that when I type in http://www.domain.com/menu.html it will load all 3 frames, or http://www.domain.com/main_top.html it will do the same. Even within sub-pages (i.e. a link in main_bottom.html that goes to page02.html) and when I type in http://www.domain.com/page02.html, it will load menu.html, main_top.html, and page02.html (in main_bottom frame).

Thanks.