Created
August 26, 2015 16:43
-
-
Save greenfox1505/4bb1f31f9c86314642bc to your computer and use it in GitHub Desktop.
Simple query parsing
This file contains hidden or 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
function getQueryParams(qs) { | |
qs = qs.split('+').join(' '); | |
var params = {}, | |
tokens, | |
re = /[?&]?([^=]+)=([^&]*)/g; | |
while (tokens = re.exec(qs)) { | |
params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]); | |
} | |
return params; | |
} | |
document.params = getQueryParams(window.location.href); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment