Created
November 26, 2014 15:12
-
-
Save niwaringo/2c7ed7d0c9e0e7807b0d to your computer and use it in GitHub Desktop.
jQuery使わず、レガシーブラウザ考えず別ドメインなら別ウィンドウにする
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
window.addEventListener("DOMContentLoaded", function() { | |
var selector = "a[href^='http']:not([href*='" + location.hostname + "'])"; | |
Array.prototype.forEach.call(document.querySelectorAll(selector), function(node) { | |
node.target = "_blank"; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment