Return to Snippet

Revision: 21266
at December 8, 2009 14:09 by nate63179


Initial Code
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
    function decode(s) {
        return decodeURIComponent(s.split("+").join(" "));
    }

    $_GET[decode(arguments[1])] = decode(arguments[2]);
});

Initial URL

                                

Initial Description
url: http://www.example.com/?foo=bar

usage: $_GET['foo'] // 'bar'

Initial Title
Grab GET params with Javascript

Initial Tags
javascript, html

Initial Language
JavaScript