I'm trying to remove my inline javascript from my website and set all intrapage links (anchor links) on a page to run the 'doThis' function.
Unfortunately I can't figure out how to set the onclick value. I'm also wondering if this is the best way to detect intrapage links (this script would be running on lots of different websites).
for(i = 0; i < document.links.length; i++){
if(document.links[i].href.indexOf(window.location.host+window.location.pathname+'#') !== -1){
document.links[i].onclick = "return doThis(this.href)";}}