Return to Snippet

Revision: 52904
at November 4, 2011 16:29 by nickaranz


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_;
  else
    return qs[1];
}

Initial URL
http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx

Initial Description
usage : var author_value = getQuerystring('author');

Initial Title
Get Query String Key Value

Initial Tags
url

Initial Language
JavaScript