Skip to content

Instantly share code, notes, and snippets.

@rianrainey
Last active December 22, 2015 08:18
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 rianrainey/6443768 to your computer and use it in GitHub Desktop.
Save rianrainey/6443768 to your computer and use it in GitHub Desktop.
Open external links in a new window.
$("a").each(function() {
var a;
a = new RegExp("/" + window.location.host + "/");
if (!a.test(this.href)) {
return $(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
return window.open(this.href, "_blank");
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment