Posted By

lancemonotone on 04/22/10


Tagged

jquery


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

millano5


jQuery: Open links in external window


 / Published in: JavaScript
 

Better than previous version. You don't have to mark up your links with 'rel=external'.

  1. jQuery('a[href^=h]').each(function(){
  2. if (this.hostname !== location.hostname) {
  3. jQuery(this).attr({
  4. target: "_blank",
  5. title: this.href + " (External link, click to open in a new window)"
  6. });
  7. }
  8. });

Report this snippet  

You need to login to post a comment.