function setActive() { 

aObj = document.getElementsByTagName('nav')[0].getElementsByTagName('a'); 

for (var i = 0; i < aObj.length; i++) { 

if (document.location.href == aObj[i].href) { 

aObj[i].className = 'active'; 

        } 
    }
} 

window.onload = setActive;