...

View Full Version : Navigation getElementById help



msjones
01-23-2009, 03:00 AM
Greetings and thank you for your assistance.

I am new to programming and mostly a designer. I am working in Drupal. I had been working with a developer but now I'm on my own. I appreciate your patience with me.:D

My design has a left hand primary navigation. In addition, I have secondary navigation for each primary navigation section it's placed in a "section_head_content" div of my design. The following piece of code calls CSS so that the current page link turns blue and the primary link is also blue (everything else remains black)


<script language="javascript">

////////////////////////////////////////////////////////////////
//Highlight current section navigation page
// This function highlights the current page in section sub-navs
////////////////////////////////////////////////////////////////

<!--

cur_page = document.location.href;

var s = document.getElementById("section_head_content");
if( s )
{
var a = s.getElementsByTagName("a");

for(var i=0,limit=a.length; i < limit; ++i)
{
if(a[i].href == cur_page)
{
a[i].className += " current_page";
}
}
}

-->
</script>

****

Primary:
ABOUT
EVENTS

Secondary
Staff ( I'm on this page)
Board

****
Super that all works. My trouble is that I loose my secondary navigation CSS style when I have a THIRD navigation.

I keep all my navigation in the "section_head_content" area. The current page link is highlighted for the staff navigation bar. The Primary link for About is highlighted but my Staff link goes black.

****

Primary:
ABOUT
EVENTS

Secondary:
Staff ( I'm in this section) :(
Board

Third:
Interns ( I'm on this page)
Volunteers

****

Gawd I hope that's clear and someone out there can help me I'm in a pickle.

I can certainly provide more information.

rangana
01-23-2009, 07:17 AM
My best bet is that the current location is not equal to that of the href's value as denoted on this part of your script:


if(a[i].href == cur_page)


...this is untested, but try to replace it with:


if(cur_page.indexOf(a[i].href)!=-1)

msjones
01-23-2009, 08:27 AM
I could Kiss kiss you right on the mouth!!! I LOVE YOU -- THANK YOU!!!!!!!!

rangana
01-23-2009, 09:05 AM
I could Kiss kiss you right on the mouth!!!

I thought kissing was meant for the lips :p

That was just for fun - glad it worked for you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum