How to append query parameter at runtime using jQuery
<p>Through JavaScript I am appending one query parameter to the page url and I am facing one strange behaiviour.</p>

<pre><code>&lt;div&gt;
    &lt;a href="Default3.aspx?id=2"&gt;Click me&lt;/a&gt;
&lt;/div&gt;


$(function () {
    window.location.href = window.location.href + "&amp;q=" + "aa";
});
</code></pre>

<p>Now I am appending <code>&amp;q=aa</code> in default3.aspx and in this page the <code>&amp;q=aa</code> is getting added continuously, causing the URL to become:</p>

<pre><code> http://localhost:1112/WebSite2/Default3.aspx?id=2&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa&amp;q=aa
</code></pre>

<p>One would say just pass it like <code>&lt;a href="Default3.aspx?id=2&amp;q=aa"&gt;Click me&lt;/a&gt;</code>, but I cant do that. The value of this query parameter is actually the value of an HTML element which is in default3.aspx. I have to add it in runtime.</p>

<p>What are the ways to achieve this?</p>
