MediaWiki:Common.js

From Van Essen Lab

(Difference between revisions)
Jump to: navigation, search
(New page: /* Any JavaScript here will be loaded for all users on every page load. */ - Main page hacks. Remove default "Main Page" header: var mpTitle = "{{MediaWiki:Mainpage}}"; var isMainPage ...)
 
Line 9: Line 9:
{
{
document.write('<style type="text/css">/*<![CDATA[*/ #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
document.write('<style type="text/css">/*<![CDATA[*/ #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
 +
}
 +
 +
 +
/* Make external links open in a new window. */
 +
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);
}
}

Latest revision as of 15:56, 11 December 2008

/* Any JavaScript here will be loaded for all users on every page load. */

/* Main page hacks. Remove default "Main Page" header */
var mpTitle = "{{MediaWiki:Mainpage}}";
var isMainPage = (document.title.substr(0, document.title.lastIndexOf(" - ")) == mpTitle);
var isDiff = (document.location.search && (document.location.search.indexOf("diff=") != -1 || document.location.search.indexOf("oldid=") != -1));

if (isMainPage && !isDiff) 
{
document.write('<style type="text/css">/*<![CDATA[*/ #siteSub, #contentSub, h1.firstHeading { display: none !important; } /*]]>*/</style>');
}


/* Make external links open in a new window. */
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);
}
Personal tools
Sums Database