Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created September 21, 2009 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfsiii/189994 to your computer and use it in GitHub Desktop.
Save jfsiii/189994 to your computer and use it in GitHub Desktop.
function getQueryString(key)
{
var url = window.location.href,
pairs = url.slice(url.indexOf('?') + 1).split('&'),
qs = window.location.qs || {},
kv;
if (! qs.cached){
for (var i=0, l=pairs.length; i<l; i++){
kv = pairs[i].split('=');
qs[unescape(kv[0])] = unescape(kv[1]);
}
qs.cached = true;
window.location.qs = qs;
}
return key ? qs[key] : qs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment