Hello, I am trying get some javascript code to track links that are marked as rel=external. The javascript will be in a tag on my site but so far I can get it it to work. Can anyone out there tell me what I am doing wrong from in the function below? function addEvent(elm, evType, fn, useCapture) { if (elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent){ var r = elm.attachEvent("on"+evType, fn); return r; } else { alert("Handler could not be removed"); } } function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); var newwindows =0; for (var i=0; i<anchors.length; i++) { var anchor = anchors[i].onmousedown = track; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") { anchor.setAttribute("target","_blank"); //newwindows++; } function track() { preload_exit = new Image(0,0); preload_exit.src="http://trackersite.com/e.jpg?ref="+url; } } } addEvent(window, "load", externalLinks); Code (markup):
I think the problem is that addEvent requires four parameters but you have provided only three. addEvent(elm, evType, fn, useCapture) addEvent(window, "load", externalLinks);