Is there a flaw in this script

by 1 replies
1
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>
#programming #flaw #script
  • 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?
    • [ 1 ] Thanks
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 1

    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?