Skip to content

Instantly share code, notes, and snippets.

@jpinnix
Created May 13, 2010 18:07
Show Gist options
  • Save jpinnix/400152 to your computer and use it in GitHub Desktop.
Save jpinnix/400152 to your computer and use it in GitHub Desktop.
jQuery - Make all external links open in new tab/window
// JQuery - Make all external links open in new tab/window
// Mashup of:
// http://travisroberts.tumblr.com/post/595428703/jquery-external-links-open-new-window
// http://snipplr.com/view.php?codeview&id=29949
$(document).ready(function() {
$("a[href*='http://']:not([href*='"+location.hostname+"'])").click( function() {
window.open( $(this).attr('href') );
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment