Is there a flaw in this script

1 replies
I tried to add this script I found online to an html file I use to store links
Code:
<body  onload="makeMemory()">
The idea was to keep my place in a file that is full of links.(I'm using this as Windows 10 won't let me use links in an Excel or Quattro Pro file and the online fixes don't seem to work.)
For some reason the script doesn't seem to work. Is there an error in it?



Code:
<script type="text/javascript">
var lastClickedLink = null;
function rememberLink() {
if (lastClickedLink) {lastClickedLink.style.color = "";}
lastClickedLink = this;
this.style.color = "red";
}
function makeMemory() {
for (var i=0; i<document.links.length; i++) {
var link = document.links[i];
if (link.addEventListener) {
link.addEventListener("click",rememberLink,false);
} else if (link.attachEvent) {
link.attachEvent("onclick",rememberLink);
} else {
link.onclick=rememberLink;
}
}
}
<script>
#flaw #script
  • Profile picture of the author wayfarer
    The methodology is a bit dated, but it looks fine, I don't see why it shouldn't work. Is the script doing anything at all? Open up the developer tools in your browser (in Chrome right click and choose "inspect"). Then click on the "Console" tab. Refresh the page. Are there any errors displayed there?
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[10758350].message }}

Trending Topics