Skip to content

Instantly share code, notes, and snippets.

@riklomas
Created July 30, 2009 10:44
Show Gist options
  • Save riklomas/158649 to your computer and use it in GitHub Desktop.
Save riklomas/158649 to your computer and use it in GitHub Desktop.
Query string in JS
var querystring = function () {
var obj = {};
var query = window.location.search.substring(1);
if (query != "") {
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var p = vars[i].split("=");
obj[p[0]] = p[1];
}
}
return obj;
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment