Created
May 23, 2014 23:42
-
-
Save kevgathuku/67ce6a431d452ff59161 to your computer and use it in GitHub Desktop.
Opens all external links on a website in a new tab
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
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<script> | |
//All external links open in a new tab | |
$(document.links).filter(function() { | |
return this.hostname != window.location.hostname; | |
}).attr('target', '_blank'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment