Richard
That rocks.
I just implemented it and it does exactly what I was doing with
convulted CSS that had to be udated each time a new link was added to
my nav.
Thanks so much for sharing.
On Wed, 10 Nov 2004 17:19:50 +1100, Richard Czeiger <[EMAIL PROTECTED]> wrote:
> Hi all :o)
>
> Just thought I'd add this. Don't know if anyone's using something like this
> but...
> Here's how to add a class to your navigation to make the current page stand
> out a bit more without putting it in the HTML.
> This also assigns the class to any sublevel nav items in nested ULs.
> Handy for those who dread going through every page and manually cutting and
> pasting the class name onto the right menu item.
>
> Variables:
> "MyMainNavigation" is the ID of the top level in your nav list
> "currentNav" is the name of the class in your stylesheet
>
> // Assign Class Name to Current Page in Side Nav
> // This goes in your external JS file
>
> function getCurrentPageLink() {
> navElements=document.getElementsByTagName("ul");
> for( var i = 0; i < navElements.length; i++ )
>
> if (navElements(i).className == 'MyMainNavigation') {
> navAnchors=navElements(i).getElementsByTagName("a");
> for( var i = 0; i < navAnchors.length; i++ )
>
> if (navAnchors(i).href == document.location.href) {
> navAnchors(i).className = 'currentNav';
> }
> }
> }
> }
> }
>
> window.onload = getCurrentPageLink;
>
> Hope this helps :o)
> Richard
>
> **
> The discussion list for http://webstandardsgroup.org/
>
> See http://webstandardsgroup.org/mail/guidelines.cfm
> for some hints on posting to the list & getting help
> **
>
>
--
Website Designer/Developer
www.nataliebuxton.com
**
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
**