-
-
Save bitzip/2dcb45ea4085fbdfe10a to your computer and use it in GitHub Desktop.
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
/** | |
* Open external links in new tab/window | |
*/ | |
// All http:// links should open in new tab/window. Internal links are relative. | |
var anchors = document.getElementsByTagName('a'); | |
for (var i = 0; i < anchors.length; i++) { | |
anchor = anchors[i]; | |
if (anchor.host !== window.location.host && | |
!anchor.hasAttribute('no-external')) { | |
anchor.setAttribute('target', '_blank'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment