Skip to content

Instantly share code, notes, and snippets.

@bgantick
Last active December 9, 2016 20:47
Show Gist options
  • Save bgantick/83c42f44165c65b6cf51 to your computer and use it in GitHub Desktop.
Save bgantick/83c42f44165c65b6cf51 to your computer and use it in GitHub Desktop.
Open external links in a new tab
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if (!a.test(this.href)) {
$(this).attr("target","_blank");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment