Created
March 22, 2014 19:52
-
-
Save luk3thomas/9713235 to your computer and use it in GitHub Desktop.
Open links in an new tab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
// Open all external links in a new window | |
$('a').filter(function(i, el){ | |
return ( | |
!$(el).attr('href').match( new RegExp( location.host ) ) && | |
$(el).attr('href').match( /^http/ ) | |
); | |
}).attr( 'target', '_blank' ); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment