javascript - Prototype rewrite of jQuery function -
i'm bit of jquery monkey , i've had site dropped on me need use simple function open links rel="external" in separate window.
in jquery this:
// make links rel=external open in new window/tab $(function() { $('a[rel*=external]').click( function() { window.open(this.href); return false; }); });
how set same function in prototype triggered unobtrusively on links rel=external attached them?
thanks
simon
edit:
following advice of 3 responses below final code is:
$(document).on('dom:loaded', function() { $$('a[rel*=external]').invoke('on','click', function(event) { window.open(this.href); event.stop(); }); });
thanks all!
event.observe(window, 'load', function() { $$('a[rel*=external]').each(function(item) { $(item).observe('click', function(event) { window.open(this.href); event.stop(); }); }); });
and here's demo.
Comments
Post a Comment