Created
January 1, 2019 20:49
-
-
Save pudly/9a96df8c56e70c352c1f88646a73f02a 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
[].forEach.call(document.querySelectorAll('a[href^=http]'), function(el) { | |
var url = el.href; | |
var base = window.location.hostname; | |
if (!url.indexOf(base)) { | |
el.setAttribute('target','_blank'); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment