Last active
August 29, 2015 14:13
-
-
Save cougrimes/94150b5e67a5a91bc7c2 to your computer and use it in GitHub Desktop.
Force all links that are not localhost to have a blank target
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function () { | |
$.expr[':'].external = function (obj) { | |
return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname) && !obj.href.match(/^javascript\:/) && !obj.href.match(/^$/) | |
}; | |
$('a:external').attr('target', '_blank'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment