-
-
Save odiak/1091777 to your computer and use it in GitHub Desktop.
外部リンク自動検出のやつ source:rskull
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
(function () { | |
var regex = /^(https?:\/\/(?:[0-9a-z\-]\.?)+(?::\d+)?)(?:\/.*)?$/, | |
replace = "$1", | |
baseURL = location.href.replace(regex, replace), | |
links = document.links, | |
i, len, href; | |
for (i = 0, len = links.length; i < len; i ++) { | |
href = links[i].href; | |
if (regex.test(href) && href.replace(regex, replace) !== baseURL) { | |
links[i].target = "_blank"; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment