Created
August 22, 2016 06:18
-
-
Save ivan-kalachikov/4fec6d3aeabded1ad5d7795e65fad515 to your computer and use it in GitHub Desktop.
js open external in new tab
This file contains hidden or 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
$("a[href^=http]").each( | |
function(){ | |
if(this.href.indexOf(location.hostname) == -1) { | |
$(this).attr('target', '_blank'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment