Skip to content

Instantly share code, notes, and snippets.

@faridv
Created July 27, 2017 08:39
Show Gist options
  • Save faridv/df5639cdb2260003ded11b7cd6316ff8 to your computer and use it in GitHub Desktop.
Save faridv/df5639cdb2260003ded11b7cd6316ff8 to your computer and use it in GitHub Desktop.
Get URL query parameters and store the in a global object
window.$_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
$_GET[decode(arguments[1])] = decode(arguments[2]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment