#JavaScript ExtLinks.js
httpから始まるa[href=""]を外部リンクに設定する。
author: Sakuya Sugo
date: 2012-05-19T00:17:48
var ExtLinks = {}; | |
ExtLinks.onBoxLink = function( event ){ | |
event.preventDefault(); | |
if( /^http|^ftp/.test(this.href) ){ | |
window.open( this.href, "" ); | |
}else{ | |
location.href = this.href; | |
} | |
return false; | |
}; | |
ExtLinks.bindBoxLink = function(){ | |
var self = this; | |
$(".box_link").bind("click", function( event ){ | |
self.onBoxLink.call( $(this).find("a").get(0), event ); | |
}); | |
}; | |
ExtLinks.bindExternalLink = function(){ | |
var settings = [ | |
"a[href^='http']" | |
]; | |
$(settings.join(",")).each(function(){ | |
$(this).attr("target","_blank"); | |
}) | |
}; |