Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

frames. a href, onclick=

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
Ok this is the situation

i have 3 frames: menu, left, content

in frame "menu" there are links
menu1
menu2
menu3

when one of these menu links is clicked 3 things should happen:
1. frame&page "menu" needs to know what menu was chosen so it can highlight the active menu. CSS a:active doesnt work good enough to do this properly. currently im using a php script to set the style according to a passed GET var.(menu.php?page=menu1)

2. frame&page "left" also needs to know what menu was chosen so it can display an image according to what menu is chosen (menu1.jpg)

3. frame "content" needs to go to the selected menu page (menu1.html)

currently im doing all this with a big messy link/onclick combo that goes something like this

Code:
<a href="menu1.html" target="content" onClick="parent.left.location='menu1left.html'; window.location='menu.php?page=menu1'">menu1</a>


this works fine :) except :( the back button is now a mess! i need to click back 3 times befor it puts the content frame back to the previous page, and after 1 and 2 clicks the menu and left frame change showing a wrong image and wrong highlited menu compared to the content.

why am i using frames u ask? well i could put left and content into 1 frame but i would rather solve this problem ;) also in left frame there is a little menu thing that would scroll with content if they where in the same frame.

im asuming theres somekind of javascript solution to this but im not a javascripter, i mean i can find my way through the basic forest of java just these complicated things arent on my level yet :)
any help apreciated
thanks
Thomas

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
try making the links in the menu frame point to another menu page (or the same one but with another parameter - since you're using PHP) and on the start of the menu page us this javascript to change the content of the other two frames:
Code:
parent.left.location = '';
parent.content.location = '';

this way your menu links should load different pages in the menu frame which automatically updates the other two pages. if you press back, you should have all the frames correspoinging to one another.

anyway I do advise you to use tables instead of frames and use PHP in this matter (concatenate files into one html that gets displayed) and then you'll have absolutelly no problem with navigation.
 
Cheers! i'll try that


anyway I do advise you to use tables instead of frames and use PHP in this matter (concatenate files into one html that gets displayed) and then you'll have absolutelly no problem with navigation

I usually do make PHP sites like this but the problem with this setup is that the whole page scrolls when a big text is in "content" i want the menu to always be at the top of the screen and the menu on the left always to be at the top under the main menu. This could be done with javascript and a floating div but this would require more script that might not be entirely cross-browser....



I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
iframes are still to buggy in any browser that isnt IE for me to use.

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
still, inside the FrameSet you could use PHP to select what pages are displayed in each of the 3 frames depending on a GET variable.
 
yay i solved it

i made a function in the left frame that changed the src of the img to a given file

i made a function in the menu frame that set the className of the selected menu to "selected" and the rest to "normal"

then i call the functions from the body onLoad in the content frame :D

it works in IE and Netscape,

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top