Graham
MARK ACTIVE NAVIGATION
Sets the class 'active' on the current item
example of very basic header structure
<div class="nav mark-active"><a href="/">home</a><a href="/blog">blog</a></div>
<script>
// Mark active navigation item (Current page)
if ( document.getElementsByClassName('mark-active') )
{
window.mark_active = function ()
{
var items = document.getElementsByClassName('mark-active');
if ( items != undefined && items != null && items [0] != undefined )
{
for (var h = 0; h < items.length; h++)
{
var item = items[h].childNodes;
var loc = decodeURI ( document.location.pathname ).replace ( ' ', '+' ).replace ( /\/__xt.+/, '' );
for (var i = 0; i < item.length; i++)
{
if (item [ i ] && item [ i ].getAttribute && item [ i ].getAttribute('href') == loc)
{
item[i].className += ' active'; break;
};
}
}
}
};
window.mark_active ();
}</script>
Copy code