Skip to content

Instantly share code, notes, and snippets.

@bjdixon
Created October 2, 2015 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjdixon/d789e9144a63c491e401 to your computer and use it in GitHub Desktop.
Save bjdixon/d789e9144a63c491e401 to your computer and use it in GitHub Desktop.
Get querystring key value pairs
// get the querystring key value pairs
// eg. http:www.example.com/document?a=1&b="2"&c=JavaScript_%D1%88%D0%B5%D0%BB%D0%BB%D1%8B
// will return {a: "1", b: "2", c: "JavaScript_шеллы"}
var params = (function getURLParams(qs) {
var pairs = {};
qs.forEach(function(param) {
var pair = param.split('=');
pairs[pair[0]] = decodeURIComponent(pair[1].replace(/\"/g, ''));
});
return pairs;
}(window.location.search.substr(1).split('&')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment