dzLib.js
 

getParameter-object (querystring)

jsEssentials
dateLib
 
jsStrings
 
Controls
 
Tools
 
Navigate
 

Description:
Easy client-side access to the querystring. The querystring is exposed as an object.

Download: code, view-source.
Targetted: all
Tested on: win32: ie6, OS X: ie5.1

Usage

 
//Access the querystring
var oQS=new getParameter();
if(oQS.strName!=null)
{
  alert('Supplied name is '+oQS.strName);
}

//Create a GET request without a form (and automatic escaping)
var oQS=new getParameter();
oQS.clearAll();
oQS.strName='Your Name';
oQS.strEmail='your.name@domain.com';
document.writeln(oQS.toString());
  

Live Demo

current QueryString

strEmail: zanstra@xs4all.nl
strName: Doeke

Want an QS-example: name and email. There's also a pretty long one.

 
//The Demo Code
var oQS=new getParameter(), bln=false;
for(var i in oQS)
{
  if(typeof oQS[i]=='string') 
  {
    document.writeln('<strong>'+i+'</strong>: '+oQS[i]+'<br>');
    bln=true;
  }
}
if(!bln) 
{
  document.writeln('<em>There\'s no querystring parameter supplied with URL</em>');
}