Created
July 18, 2011 16:14
-
-
Save rskull/1089981 to your computer and use it in GitHub Desktop.
外部リンクを自動検出して、新しいタブで開くようにしてくれるはずです。
This file contains hidden or 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
//外部リンク自動判断スクリプト | |
onload = function () { | |
var CheckURL = document.links; | |
for(i=0;i<CheckURL.length;i++) { | |
var links = CheckURL[i].href.split('/'); | |
if((links[0].match(/[http|s]:/)) && (location.hostname != links[2])) { | |
CheckURL[i].target = '_blank'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment