Skip to content

Instantly share code, notes, and snippets.

@rskull
Created July 18, 2011 16:14
Show Gist options
  • Save rskull/1089981 to your computer and use it in GitHub Desktop.
Save rskull/1089981 to your computer and use it in GitHub Desktop.
外部リンクを自動検出して、新しいタブで開くようにしてくれるはずです。
//外部リンク自動判断スクリプト
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