Skip to content

Instantly share code, notes, and snippets.

@SafeerH
Created September 7, 2015 11:49
Show Gist options
  • Save SafeerH/ac9337c417770a356798 to your computer and use it in GitHub Desktop.
Save SafeerH/ac9337c417770a356798 to your computer and use it in GitHub Desktop.
Get query string from JavaScript
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