wilcosky
Technical User
- Feb 18, 2007
- 4
I have this script on my page that makes my links in my menu become highlighted when clicked then when the next link is clicked the previous link goes back to normal and the new link because highlighted etc. anyway, it works in firefox and safari but not internet explorer... any know why?
<script type="text/javascript">
var lastClickedLink = null;
function rememberLink() {
if (lastClickedLink) {lastClickedLink.style.color = "green";lastClickedLink.style.backgroundColor = "white";lastClickedLink.style.fontStyle = "normal";}
lastClickedLink = this;
this.style.color = "white";
this.style.backgroundColor = "green";
this.style.fontStyle = "italic";
}
function makeMemory() {
for (var i=0; i<document.links.length; i++) {
var link = document.links;
if (link.addEventListener) {
link.addEventListener("click",rememberLink,false);
} else if (link.attachEvent) {
link.attachEvent("onclick",rememberLink);
} else {
link.onclick=rememberLink;
}
}
}
</script>
oh yeah, I do have the body onload tag in the beginning of the body in the html, just thought I'd mention that before someone said, well I know whats wrong, you have to people body onload blah blah in the body... I got that... and like I said it works in all browsers BUT internet explorer.
If noone knows whats wrong, then does anyone know of a script that will do what im talking about... cause I have a website where everything opens up in the same page using ajax. So I want a menu that will let the user know what section that are in.
<script type="text/javascript">
var lastClickedLink = null;
function rememberLink() {
if (lastClickedLink) {lastClickedLink.style.color = "green";lastClickedLink.style.backgroundColor = "white";lastClickedLink.style.fontStyle = "normal";}
lastClickedLink = this;
this.style.color = "white";
this.style.backgroundColor = "green";
this.style.fontStyle = "italic";
}
function makeMemory() {
for (var i=0; i<document.links.length; i++) {
var link = document.links;
if (link.addEventListener) {
link.addEventListener("click",rememberLink,false);
} else if (link.attachEvent) {
link.attachEvent("onclick",rememberLink);
} else {
link.onclick=rememberLink;
}
}
}
</script>
oh yeah, I do have the body onload tag in the beginning of the body in the html, just thought I'd mention that before someone said, well I know whats wrong, you have to people body onload blah blah in the body... I got that... and like I said it works in all browsers BUT internet explorer.
If noone knows whats wrong, then does anyone know of a script that will do what im talking about... cause I have a website where everything opens up in the same page using ajax. So I want a menu that will let the user know what section that are in.