Is there better way reading values form url in JavaScript
<p>I came across old web application which has the code to read the parameters from the URL of the site. The code is full of string processing.</p>

<pre><code>http://hostname.domain[port number]/application name?arg1=value1...&amp;argN=valueN 
</code></pre>

<p>Considering that URL parameters are always encoded it is litter difficult to rely on string processing. Also not sure if one can rely 100% on the URLEncode/Decode functions of the JavaScript.</p>

<pre><code>function getURLParameters(){
if (location.search != "")
{
    var x = location.search.substr(1).split(";")
    for (var i=0; i&lt;x.length; i++)
    {
        var y = x[i].split("=");
        alert("Key '" + y[0] + "' has the content '" + y[1]+"'")
    }
}   
}
</code></pre>

<p>Now that made me think if there is any better way we can read values from URL ? OR should we go ahead and change the approach itself by sending values using POST/dumping JSON object on cliente ? Please help me with this.</p>
