Description: This will allow you to grab variable-value pairs from the URL of a page, much like PHP, ASP, .NET or JSP grabs data from the URL. It places foo=bar data in a JavaScript array called _GET and can be referenced just like $_GET in PHP.
File name: get_reader.js
var _GET = {};
function readURL() {
var tLoc = "", tPairs = "";
var tGet = [];
var foundGet = -1;
tLoc = window.location + "";
foundGet = tLoc.indexOf('?');
if (foundGet > -1) {
tLoc = tLoc.substring(foundGet + 1, tLoc.length);
tPairs = tLoc.split('&');
for (var i = 0; i < tPairs.length; i++) {
tGet = tPairs[i].split('=');
_GET[tGet[0]] = decodeURIComponent(tGet[1].replace(/\+/g,' '));
}
}
}
readURL();
Try it out: Enter any variable-value pair in the URL that you want, or click one of the sample links below:
Note: Due to the Yahoo Ads, the last _GET item has ?YYYYDD appended to the value for some reason. The YYYY is the year and the DD is the day of the month. Without Yahoo Ads screwing this up, it works fine.