Return to Snippet

Revision: 26281
at March 29, 2011 03:58 by lancemonotone


Updated Code
jQuery('a[href^=h]').each(function(){
    if (this.hostname !== location.hostname) {
      jQuery(this).attr({
        target: "_blank",
        title: this.href + " (External link, click to open in a new window)"
      });
    }
  });

Revision: 26280
at April 22, 2010 10:14 by lancemonotone


Initial Code
$('a[rel=external]').click(function(e){
    e.preventDefault();
    window.open($(this).attr('href'));
  });

Initial URL

                                

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

Initial Title
jQuery: Open links in external window

Initial Tags
jquery

Initial Language
JavaScript