I have a small problem with my unobtrusive onclick event in javascript…
it opens a new window if you click on a link in the html. However, after opening the new window/tab it also follows the link in the old window (which it shouldn’t..) I’am using prototype. This occurs only in IE7 en FF3 , in IE6 Opera everything is fine and behaves like it should.
below is my snippet, any help/suggestion is higly appreciated!
[code]
function external_link(link) {
var el = Event.element(link);
window.open(el.href);
Event.stop(event);
/* this is where it should stop following the link in the old window */
return false;
}
function init() {
var links = $A(document.getElementsByTagName(‘a’));
links.each(function(link) {
if (link.getAttribute(‘rel’) == ‘external’) {
Event.observe(link,’click’,function(e){ external_link(e); },false);
}
});
}
Event.observe(window,’load’,init);