MediaWiki:Common.js

From Van Essen Lab

Revision as of 15:56, 11 December 2008 by WikiSysop (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes. Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh); Konqueror: click Reload or press F5; Opera: clear the cache in Tools → Preferences; Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

/* 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