PDA

View Full Version : help: Multiple links targeting multiple frames on the one page


nNemethon
05-27-2004, 04:58 AM
Hello to all. ;)

I am in the middle of constructing a page that has multiple frames and also multiple links. confused? Not yet you aint ;)

Basically, I have a menu in one frame with approx 9 links. These links are all to open a corresponding document into 2 separate OTHER frames. 1 frame being the standard target-type, full information section, and the other frame being a heading to show what area of the menu you are browsing.

The question is this: How can I make all the menu items in the one frame do this? I can make one menu item change 2 diff frames, but I do not know how to code multiple links in the same frame to do such.

The general "change 2 frames" code I use is this:

<!----hide
function change2()
{
parent.frame1.location="frame1.html";
parent.frame2.location="frame2.html";
}
//------>
</SCRIPT>
<A HREF="javascript:change2()">LINK TEXT</A>

And the layout is this:

LINK1
LINK2
LINK3
etc...

FRAME1 (pretend this is a frame) ;)
FRAME2 (Ditto)

The links are in a separate frame, but all links will need to change the same 2 frames.

The page is coded for IE4+ so version-dependant code is a necessity unfortunately. (I run IE5+)

I thank-you if you can help me as I unable to find an answer.

nNemethon

agent002
05-27-2004, 07:01 AM
We can make your change2() function take arguments:
function changeFrames(){
for(var i = 0; i < arguments.length; i += 2){
parent[arguments[i]].location.href = arguments[i+1];
}
}
You can then call it using:
<a href="javascript:changeFrames('frame1', 'frame1.html', 'frame2', 'frame2.html');">Change</a>

nNemethon
05-27-2004, 09:14 AM
Thank you very much for your help. Both on this and the scrollbar color problem with IE5+

It took me a little bit of working out, and then to my chagrin, as all the coding was correct, all I had to do was rename one of the target frames from 'name' to 'list'. ;)

Didn't realise that 'name' could not be used as a target name. :D

TY again.

nNemethon