Created
October 2, 2015 00:50
-
-
Save bjdixon/d789e9144a63c491e401 to your computer and use it in GitHub Desktop.
Get querystring key value pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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