jQueryで外部リンクとPDFファイルを別タブで開く
jQuery(document).ready(function ($) {
// PDFファイルリンクに target="_blank"を付ける
$("a[href*='.pdf']").attr("target","_blank");
// 外部リンクに target="_blank"を付ける
$("a[href]").each(function() {
if (!this.href.match(new RegExp("^(#|\/|(https?:\/\/" + location.hostname + "))"))) {
$(this).attr("target", "_blank");
}
});
});