website_template/js/main.js

23 lines
546 B
JavaScript
Raw Normal View History

2014-07-29 02:50:38 +02:00
/* Some scripts and stuff
--------------------------*/
/* Target-Blank for CSS-Class "external"
--------------------------*/
function externalLinks() {
if (!document.getElementsByTagName) {return;}
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute("href") && anchor.getAttribute("class") === "external") {
anchor.target = "_blank";
}
}
}
window.onload = externalLinks;
// or in jQuery
/*
$('a[rel="external"]').attr('target', '_blank');
*/