Click to See Complete Forum and Search --> : Changing 2 frames at once but not the one which the link is in?
Okay, here's my problem:
I have a page with 3 frames: One which displays the menu (frame name="menu")
One which displays the body of the text (frame name="main")
And one which displays the links related to that subject matter (frame name="links")
I would like that, by a simple click on one of the links inside the "menu" frame, the content of both "main" and "links" frames would be changed but not the "menu" one!.
I know that to change two frames at once I have to use Javascript, but I only know this code:
<a href="main.html"
onClick="window.self.location='links.html'" target="main">
Main Page</a>
But, when I use this, the menu disappears and features the links... :(
Do you know what I should change in this code so that the links appear inside the "links" frame?
Thanx for your help!
Khalid Ali
10-14-2003, 08:51 AM
onclick="parent.frameName.location.href='someResource.html';"
will do,make sure you use the above for both frames
:( Doesn't work!
It gives me a "expected ';'" error... Might be because the links are inside a drop down menu (made with javascript)
mv2_lien[0] += '<A HREF="main.html" target="main" CLASS=mv2style onclick="parent.topleft.location.href='links.html';"> . Homepage</A><BR>';
Must create a conflict somehow...
:(
requestcode
10-14-2003, 09:10 AM
You need to excape the single quotes with in your string since you are using thos to enclose the string. try this:
mv2_lien[0] += '<A HREF="main.html" target="main" CLASS=mv2style onclick="parent.topleft.location.href=\\'links.html\\'"> . Homepage</A><BR>';
Khalid Ali
10-14-2003, 09:16 AM
Code works fine,as requestcode already mentioned,you will need to escape the single qoutes around url.
use his updated code above
Now my drop down menu works but links change only the contant of "main" frame and not of "topleft" (the links one):confused:
Khalid Ali
10-14-2003, 09:28 AM
:confused:
not sure if I follow you,here is my guess
onclick="parent.topleft.location.href=\'links.html\'"
you will need to add the second resource for second frame as well. e.g
onclick="parent.topleft.location.href=\'links.html\';parent.secondFrameName.location.href='url.html'"
don't forget to escape the single qoutes
Well, here's my frameset:
<html>
<head>
<title>Whatever</title>
</head>
<frameset cols="25%,75%">
<frameset rows="50%,50%">
<frame src="links_intro.html" name="topleft">
<frame src="menu.html" name="bottomleft">
</frameset>
<frame src="main.html" name="main">
</frameset>
<noframes>
<body>
Viewing this page requires a browser capable of displaying frames.
</body>
</noframes>
</html>
The drop down menu is located in the frame named "bottomleft" and I want that each click on one of the menu links changes the content of both "topleft" and "main"
Using this:
mv2_lien[0] += '<A HREF="main.html" target="main" CLASS=mv2style> . Homepage</A><BR>'; in my menu works perfectly to change the content of "main" frame, but when I add the code you provided (even with the necessary "\"s before the quotation marks) it doesn't change the content of "topleft":(
Does it make more sense now?
lillu
10-14-2003, 10:00 AM
Put this into menu.html :
<a href="main.html" target="main"></a>
Put this into main.html :
<script language="javascript">
top.topleft.location="links_intro.htm"
</script>
Woohoo!
This works perfectly!... Thanx for your help everybody!;)