MediaWiki:Monomookwebis.js: Unterschied zwischen den Versionen
Aus Webis
Zur Navigation springenZur Suche springen
(Die Seite wurde neu angelegt: externalLinks = function() { if (!document.getElementsByTagName) { return; } var anchors = document.getElementsByTagName("a"); for (var i = 0; i < anchors.length;...) |
Keine Bearbeitungszusammenfassung |
||
Zeile 6: | Zeile 6: | ||
for (var i = 0; i < anchors.length; i++) { | for (var i = 0; i < anchors.length; i++) { | ||
var anchor = anchors[i]; | var anchor = anchors[i]; | ||
if (anchor.getAttribute("href") && | if (anchor.getAttribute("href") && | ||
anchor.getAttribute("rel") != null && | anchor.getAttribute("rel") != null && | ||
(anchor.getAttribute("rel").indexOf("external") >= 0 || | (anchor.getAttribute("rel").indexOf("external") >= 0 || | ||
anchor.getAttribute("rel").indexOf("nofollow") >= 0) | anchor.getAttribute("rel").indexOf("nofollow") >= 0) | ||
Zeile 14: | Zeile 14: | ||
} | } | ||
} | } | ||
} | |||
if (window.addEventListener) { | |||
window.addEventListener("load", externalLinks, false); | |||
} | |||
else if (window.attachEvent) { | |||
window.attachEvent("onload", externalLinks); | |||
} | } |
Version vom 10. Juni 2009, 11:24 Uhr
externalLinks = function() {
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("rel") != null &&
(anchor.getAttribute("rel").indexOf("external") >= 0 ||
anchor.getAttribute("rel").indexOf("nofollow") >= 0)
) {
anchor.target = "_blank";
}
}
}
if (window.addEventListener) {
window.addEventListener("load", externalLinks, false);
}
else if (window.attachEvent) {
window.attachEvent("onload", externalLinks);
}