window.location.href does not change the URL
<p>I would like to change the URL that appears once a form has been submitted although the code below does not appear to do what I would like it to do. How do I change the URL in the address bar?</p>

<p><strong>CODE</strong></p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XMHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html;charset=UTF-8" /&gt;
    &lt;meta http-equiv="content-language" content="en-us" /&gt;
    &lt;meta http-equiv="cache-control" content="no-cache" /&gt;
    &lt;meta http-equiv="pragma" content="no-cache" /&gt;
    &lt;meta name="keywords" content="" /&gt;
    &lt;meta name="description" content="" /&gt;
    &lt;meta name="author" content="" /&gt;
    &lt;meta name="copyright" content="&amp;copy; 2012" /&gt;
    &lt;meta name="robots" content="noindex, nofollow" /&gt;

    &lt;title&gt;sample form&lt;/title&gt;

    &lt;link rel="stylesheet" type="text/css" media="all" href="" /&gt;

    &lt;style type="text/css"&gt;

    &lt;/style&gt;

    &lt;script type="text/javascript"&gt;

        var testurl = window.location.href;
        if(testurl == "file:///C:/Users/user/Desktop/sample_form.html?q=test&amp;submit=submit") {
            testurl = testurl.replace(/q=[^&amp;]+&amp;[a-z]+\=[a-z]+/,'test');
            alert(testurl);
        }

    &lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

    &lt;form name="sampleform" id="sampleform" method="get" action="sample_form.html"&gt;
        &lt;input type="text" name="q" value="" id="q" /&gt;
        &lt;input type="submit" name="submit" value="submit" id="submit" /&gt;
    &lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>
