Skip to content

Instantly share code, notes, and snippets.

@igorvolnyi
Created December 14, 2018 03:59
Show Gist options
  • Save igorvolnyi/5fda514fa4b4668f1377e16c4923e507 to your computer and use it in GitHub Desktop.
Save igorvolnyi/5fda514fa4b4668f1377e16c4923e507 to your computer and use it in GitHub Desktop.
Get GET parameters in your browser as JS object.
function getGetParameters() {
var s1 = location.search.substring(1, location.search.length).split('&'),
r = {}, s2, i;
for (i = 0; i < s1.length; i += 1) {
s2 = s1[i].split('=');
r[decodeURIComponent(s2[0])] = decodeURIComponent(s2[1]);
}
return r;
}
window.ServerData = getGetParameters();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment