website_template/js/scripts.js

23 lines
546 B
JavaScript
Raw Normal View History

2014-06-29 12:46:19 +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');
*/