Skip to content

Instantly share code, notes, and snippets.

@n3tr
Created March 24, 2012 06:44
Show Gist options
  • Save n3tr/2179123 to your computer and use it in GitHub Desktop.
Save n3tr/2179123 to your computer and use it in GitHub Desktop.
Get Query String from URI
function getQuerystring(uri, key, default_)
{
if (default_==null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(uri);
if(qs == null)
return default_;
else
return qs[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment