HTML
<div id="top" class="shadow">
<ul class="gprc">
<li><a href="http://www.domain.com/">Home</a></li>
<li><a href="http://www.domain.com/link1/">Text1</a></li>
<li><a href="http://www.domain.com/link2/">Text2</a></li>
<li><a href="http://www.domain.com/link3/">Text3</a></li>
<li><a href="http://www.domain.com/link4">Text4</a></li>
</ul>
Javascript
window.onload = setActive;
function setActive() {
aObj = document.getElementById('top').getElementsByTagName('a');
var found = false;
for (i = 0; i < aObj.length; i++) {
if (document.location.href.indexOf(aObj[i].href) >= 0) {
aObj[i].className = 'active';
found = true;
}
}
if (!found) {
aObj[0].className = 'active';
}
}
The problem is that the menu home link remains selected or active all the time even if i click on other links and I would like to make it not selected on loading of the page and also to remain non-selected while other link that i clicked and i am on the specific landing page remains selected. Please only Javascript no JQUERY.