Created
May 24, 2019 13:42
-
-
Save nurumayuapp/ff2bb5bf50624d4397cda76e43b5f47f to your computer and use it in GitHub Desktop.
Anchor tag automatic targeting
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> | |
var anchors = document.getElementsByTagName('a'); | |
for(var i = 0; i < anchors.length; i++) { | |
var a = anchors[i]; | |
if (!a.href.length || ~a.href.indexOf(location.host)) { continue } | |
a.target = '_blank'; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment