Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Navigation getElementById help

    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.

    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)

    Code:
    <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.
    Last edited by msjones; 01-23-2009 at 03:03 AM.

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    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:
    Code:
    if(a[i].href == cur_page)
    ...this is untested, but try to replace it with:
    Code:
    if(cur_page.indexOf(a[i].href)!=-1)
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you

    I could Kiss kiss you right on the mouth!!! I LOVE YOU -- THANK YOU!!!!!!!!
    Last edited by msjones; 01-23-2009 at 08:31 AM. Reason: it worked it worked!!!

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Quote Originally Posted by msjones View Post
    I could Kiss kiss you right on the mouth!!!
    I thought kissing was meant for the lips

    That was just for fun - glad it worked for you.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •