Dear guys!
Im trying to figure out a problem with the most basic of javascript functions. Im trying to add the class “here” to each link in the navigation using javascript as illustrated by a book Im using. However, I seem to be missing something as the javascript isn’t doing its job! :injured:
Heres what Im talking about:
CSS:
[code=html]#navigation a.here:link,
#navigation a.here:visited,
#navigation a.here:hover,
#navigation a.here:active
{color: #eef;
background-color: #799;}
Javascript:
[QUOTE]
function highlightPage(){
if (!document.getElementsByTagName) return false;
if (!document.getElementById) return false;
if (!document.getElementById(“navigation”)) return false;
var nav = document.getElementById(“navigation”)
for (var i=0; i<links.length; i++){
var linkurl = links[i].getAttribute(“href”);
var currenturl = window.location.href;
if (currenturl.indexOf(linkurl) != -1){
links[i].className = “here”;
}
}
}
For the code in its entirety, the test page is [URL=”www.javascript.net16.net”]here
There could be a problem with the addLoadEvent function, but I can’t see jack!
(don’t make fun of the design)