Hyperlink click is not firing
问题 I'd like to catch click on hyperlink with JavaScript. I used this code : for (var i = 0; i < document.links.length; i++) { document.links[i].onclick = function() { doSomething(); } } On normal hyperlink <a href="index.html">Home</a> everything works but on link to pdf file <a href="tmp.pdf">tmp.pdf</a> action doSomething(); is not called. My page is redirected to tmp.pdf without firing click event. I don't have a idea why. Can you advise me what is problem. I'd like to avoid jQuery. 回答1: You