Skip to content

Instantly share code, notes, and snippets.

@alikrc
Last active August 29, 2015 14:14
Show Gist options
  • Save alikrc/0708c98e1a57367b7a78 to your computer and use it in GitHub Desktop.
Save alikrc/0708c98e1a57367b7a78 to your computer and use it in GitHub Desktop.
[javascript snippet] get query string parameter on url
//returns query parameters as object
function getQueryString() {
var result = {}, queryString = location.search.slice(1),
re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment