Skip to content

Instantly share code, notes, and snippets.

@avireni
Created April 12, 2012 21:34
Show Gist options
  • Save avireni/2371151 to your computer and use it in GitHub Desktop.
Save avireni/2371151 to your computer and use it in GitHub Desktop.
Automatic external link open in New Window
$('a').each(function() {
var a = new RegExp('/' + [removed].host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment