User:Interiot/js/RealTitle.js

This is an old revision of this page, as edited by Interiot (talk | contribs) at 07:22, 16 November 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// copied from http://fr.wikipedia.org/w/index.php?title=-&action=raw&gen=js

// The function looks for a banner like that:
// <div id="RealTitleBanner">Div that is hidden
//   <span id="RealTitle">title</span>
// </div>
// An element with id=DisableRealTitle disables the function.
addOnloadHook(function() {
	try {
		var realTitleBanner = document.getElementById("RealTitleBanner");
		var isPastable = 1;    // is it spelled "pasteable"?
		if (!realTitleBanner) {
			isPastable = 0;
			realTitleBanner = document.getElementById("RealTitleBannerUnpastable");
		}
		if (realTitleBanner) {
			if (!document.getElementById("DisableRealTitle")) {
				var realTitle = document.getElementById("RealTitle");
				if (realTitle) {
					var h1 = document.getElementsByTagName("h1")[0];
					if (isPastable && h1) {
						h1.innerHTML = realTitle.innerHTML;
						realTitleBanner.style.display = "none";
					}
					document.title = realTitle.innerHTML + " - Wikipedia, the free encyclopedia";
				}
			}
		}
	} catch (e) {
		/* Something went wrong. */
	}
});