window.addEventListener('DOMContentLoaded', function() { var fn = function(e) { window.open(this.href); e.preventDefault(); }; for(var i = 0, links = document.links; i < links.length; i++) { links[i].addEventListener('click', fn); } });