Skip to content

Instantly share code, notes, and snippets.

@yannickoo
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yannickoo/958edcfbc145a644f369 to your computer and use it in GitHub Desktop.
Save yannickoo/958edcfbc145a644f369 to your computer and use it in GitHub Desktop.
Open all links in new tab
$('a').on('click', function () {
var a = new RegExp('/' + window.location.host + '/');
if (!a.test(this.href)) {
$(this).click(function (e) {
e.preventDefault();
e.stopPropagation();
window.open(this.href, '_blank');
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment