Skip to content

Instantly share code, notes, and snippets.

@hoodasaad
Created December 7, 2016 10:02
Show Gist options
  • Save hoodasaad/b521ec5a0ade50156f0abc1de846df4f to your computer and use it in GitHub Desktop.
Save hoodasaad/b521ec5a0ade50156f0abc1de846df4f to your computer and use it in GitHub Desktop.
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
$_GET[decode(arguments[1])] = decode(arguments[2]);
});
You can now access the $_GET variables like so:
alert($_GET['some_variable']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment