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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nav bar and sub nav bar question...this is deep and requires theory...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
okay, on my site i have a main nav and a sub nav, the latter is specific to the first.

i can almost figure out how the sub nav will work...when you are on a specific page, let's say 'donuts.html', the corresponding button on the sub nav named 'donuts' will become highlighted or have an arrow...that's almost simplistic.

the main nav is the problem. since the sub nav pages will be under a specific directory, like our 'donuts.html' example would be under the directory named '/sweets/', under '/sweets/' will be many pages of types of sweets, each corresponding to specific buttons on the sub nav.
how would you highlight the button 'Sweets' on the main nav and always keep it highlighted while operating in the sub nav area? (just short of listing all possible sub pages in that directory using 20+ 'if' statements, which could compound infinitely by the number of possible main nav options and their corresponding sub nav options)

i'm building the main nav and sub nav on the fly using an external js page, so simply changing the main nav and sub nav options bgcolor on each specific page is not a viable solution.

i would also like to keep it IE4+ and NS4+ compatible. i can, however, be specific for each browser. like 'if (NS) {xxxxx} or 'if (IE) {xxxxx}.

thank you again, this place is so good to me...

- crispy

 
Instead of checking for all possible subpages. Have each subpage set a global variable to indicate which main menu option should be highlighted. At the top of each page in "sweets" code:
Code:
<script language=&quot;javascript&quot;>
menuitem = &quot;sweets&quot;;
</script>
Then you can check the value of the variable menuitem to see which menu item should be hightlighted.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top