Jestem w miarę początkujący w js i aktualnie borykam się z małym problemem. Mianowicie chodzi mi o następujący efekt:

Jeśli otwartą mamy podstronę index.html - powinien się podświetlać home, jesli services.html - services no i tak dalej...
Oto mój niedziałający kod (ma wcięcia ale zrównuje tu do lewej... Wrzucam poniżej obrazek dla każdego komu łatwiej ogarnąć wizualnie):
Cytat
function hoover() {
if(window.location.href.indexOf("index.html")){
document.getElementById("home").src = "images/home_hover.png";
}
else{
if(window.location.href.indexOf("services.html")){
document.getElementById("services").src = "images/services_hover.png";
}
else{
if(window.location.href.indexOf("offert.html")){
document.getElementById("offert").src = "images/offert_hover.png";
}
else{
if(window.location.href.indexOf("gallery.html")){
document.getElementById("gallery").src = "images/gallery_hover.png";
}
else{
if(window.location.href.indexOf("about.html")){
document.getElementById("about").src = "images/about_hover.png";
}
else{
if(window.location.href.indexOf("contact.html")){
document.getElementById("contact").src = "images/contact_hover.png";
}
}
}
}
}
}
}
if(window.location.href.indexOf("index.html")){
document.getElementById("home").src = "images/home_hover.png";
}
else{
if(window.location.href.indexOf("services.html")){
document.getElementById("services").src = "images/services_hover.png";
}
else{
if(window.location.href.indexOf("offert.html")){
document.getElementById("offert").src = "images/offert_hover.png";
}
else{
if(window.location.href.indexOf("gallery.html")){
document.getElementById("gallery").src = "images/gallery_hover.png";
}
else{
if(window.location.href.indexOf("about.html")){
document.getElementById("about").src = "images/about_hover.png";
}
else{
if(window.location.href.indexOf("contact.html")){
document.getElementById("contact").src = "images/contact_hover.png";
}
}
}
}
}
}
}

w html rozwiązałem sprawę bardzo prosto:
Cytat
<body onLoad="hoover()">
Czemu to nie działa... Pomożecie?
Jestem otwarty na alternatywy i chętnie się czegoś naucze
