User:Interiot/Tool2/code.js

This is an old revision of this page, as edited by Interiot (talk | contribs) at 23:56, 26 December 2005. 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.
// see http://en.wikipedia.org/wiki/User:Interiot/Tool2 for instructions on adding this to your monobook.js

// to run this tool on other servers, copy this script there, and update the following URL
// for example: "User:Interiot/Tool2/code.js"
var tool2_url = "User:Interiot/Tool2/code.js";

function addOnloadFunction(f) {
  if (window.addEventListener) window.addEventListener("load",f,false);
  else if (window.attachEvent) window.attachEvent("onload",f);
  else {
    var oldOnload='_old_onload_'+addOnloadFunction.uid;
    addOnloadFunction[oldOnload] = window.onload ? window.onload : function () {};
    window.onload = function() { addOnloadFunction[oldOnload]();  f(); }
    ++addOnloadFunction.uid;
  }
}

addOnloadFunction(function() {
  var path_len = document.___location.pathname.length;
  alert (document.___location.pathname.substring(path_len - tool2_url.length, path_len));
});