Ok I have a simple menu of div tags like this:
where the 'menuout' class is the same as "leftmenu" - this all works fine.<a href="home.html"><div id="home.html" class="leftmenu" onmouseover="this.className='menuover'" onmouseout="this.className='menuout'">Home</div></a>
<a href="about.php"><div id="about.php" class="leftmenu" onmouseover="this.className='menuover'" onmouseout="this.className='menuout'">About</div></a>
etc, etc..
BUT: now i have added a javascript function like this
that finds which div corresponds to the active anchor and changes that div class to "active" which makes the div background a little darker than either of the other classes.function checkActive() {
var div = document.getElementsByTagName("div");
if (window.location.href.substr(location.href.length - 1, 1) == '/') {
var loc = window.location.href + 'home.html';
}
else {
var loc = window.location.href;
}
for(var i=0; i < div.length; i++) {
if (div[i].id == loc) {
div[i].setAttribute("class", "active");
div[i].setAttribute("className", "active");
}
}
}
does someone know of an easy way to reset the class onmouseout to whatever it was before, either the default class or the active class? Besides refreshing the page? I can't just use the 'menuout' class anymore because i added the script for active links...
thanks.


Reply With Quote
Bookmarks