Skip to content

Instantly share code, notes, and snippets.

@JWebCoder
Last active December 23, 2015 00:19
Show Gist options
  • Save JWebCoder/6553117 to your computer and use it in GitHub Desktop.
Save JWebCoder/6553117 to your computer and use it in GitHub Desktop.
Get Url params
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;
}
var query = getQueryParams(document.location.search);
alert(query.foo);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment