Skip to content

Instantly share code, notes, and snippets.

@greenfox1505
Created August 26, 2015 16:43
Show Gist options
  • Save greenfox1505/4bb1f31f9c86314642bc to your computer and use it in GitHub Desktop.
Save greenfox1505/4bb1f31f9c86314642bc to your computer and use it in GitHub Desktop.
Simple query parsing
function getQueryParams(qs) {
qs = qs.split('+').join(' ');
var params = {},
tokens,
re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
}
return params;
}
document.params = getQueryParams(window.location.href);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment