git @ Cat's Eye Technologies The-Dipple / master javascript / querystring.html
master

Tree @master (Download .tar.gz)

querystring.html @masterraw · history · blame

<!DOCTYPE html>
<!--
SPDX-FileCopyrightText: Chris Pressey, the original author of this work, has dedicated it to the public domain.
For more information, please refer to <https://unlicense.org/>
SPDX-License-Identifier: Unlicense
-->
<head>
  <meta charset="utf-8">
  <title>Parse Querystring</title>
  <style>
#status { border: 1px solid blue; }
  </style>
</head>
<body>

<h1>Parse Querystring</h1>

<p id="status"></p>

</body>
<script type="text/javascript">
    function parseQuerystring(qs) {
        qs = qs || window.location.search.substring(1);
        var object = {};
        var pairs = qs.split('&');
        for (var i = 0; i < pairs.length; i++) {
            var components = pairs[i].split('=');
            var key = decodeURIComponent(components[0]);
            var value = decodeURIComponent(components[1]);
            object[key] = value;
        }
        return object;
    }

    document.getElementById('status').innerHTML = uneval(parseQuerystring());
</script>