Created
July 27, 2017 08:39
-
-
Save faridv/df5639cdb2260003ded11b7cd6316ff8 to your computer and use it in GitHub Desktop.
Get URL query parameters and store the in a global object
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
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