var links = document.getElementsByTagName("A"); for(var i = 0, l = links.length; i < l; i++) (function(link) { link.onmouseover = function() { alert(link.href); } })(links[i]);