Posted By

brianyang on 12/23/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

saman
AtticBoy
mmcachran


Open External Links In New Window


 / Published in: jQuery
 

  1. $('a').each(function() {
  2. var a = new RegExp('/' + window.location.host + '/');
  3. if(!a.test(this.href)) {
  4. $(this).click(function(event) {
  5. event.preventDefault();
  6. event.stopPropagation();
  7. window.open(this.href, '_blank');
  8. });
  9. }
  10. });

Report this snippet  

You need to login to post a comment.