User:Addshore/urlparameters.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
var UrlParameters = new Array ();
 readparams();
 
 function readparams() {
  var asReadInUrlParameters;
  var asReadInUrlParameter;
 
  // Get URL parameters
  asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
  for (i = 0; i < asReadInUrlParameters.length; i++) {
    asReadInUrlParameter = asReadInUrlParameters[i].split("=");
    UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
  }
 }

/* function UrlParameters(params) {
 if(location.href.indexOf(params + "=") != -1) {
  var parm = location.href.substring(location.href.indexOf(params) + params.length++).split("=")[1];
  return decodeURIComponent((parm.indexOf("&") != -1 ? parm.split("&")[0] : parm));
 } else {
   return undefined;
 }
} */

// Copied  lots originally from from [[User:DerHexer]] with extreme pride