From my programming archive:
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r[r.length]=m[1];
return r;
}
If the value doesn't exist, an empty array is returned.
If the value exists, an array is return that has one item, the value.
If several values with the name exists, an array containing each value is returned.
Examples:
var param1var = querystring("param1")[0];
document.write(querystring("name"));
if (querystring('id')=='42') alert('We apoligize for the inconvenience.');
if (querystring('button').length>0) alert(querystring('info'));