Skip to content

Instantly share code, notes, and snippets.

@namusyaka
Created July 19, 2011 05:31
Show Gist options
  • Save namusyaka/1091385 to your computer and use it in GitHub Desktop.
Save namusyaka/1091385 to your computer and use it in GitHub Desktop.
外部リンク自動検出のやつ source:rskull
javascript:function AutoCheckURL() {
var HostURL = new RegExp(location.hostname + "(\\:[0-9]+)?"),
CheckURL = document.links;
for(var i = 0; i < CheckURL.length; ++i)
if(!HostURL.test(CheckURL[i].href.split('/')[2]))
CheckURL[i].target = '_blank';
}
AutoCheckURL();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment