Menus - Active Page CSS Classes

The :active option in CSS is actually for an active link on the "calling" page, not the destination.. stupid, but true...

Heres a quick way to determine and change the class of current page.... it only works if the current url matches the menus url...

<script>
linkcount=document.links.length;
for (i=0;i<linkcount;i++) {
  if (document.links[i].href == document.URL) 
     document.links[i].className = 'menu-active';
}
</script>

and in your CSS you would need to have something like

A.menu-active, A.menu-active:visited { color: black; }

 

Index Previous Next