Return to Snippet

Revision: 9625
at November 14, 2008 16:36 by charmcitycoder

Initial Code
function getQuerystring(key, default_)
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
    return qs[1];

Initial URL

Initial Description
Many thanks to for this one. Works like a charm. Usage is similar to server side built-in functions.

Initial Title
Function - Get querystring variable

Initial Tags

Initial Language