How to append query parametr @runtime using jquery

Posted by Wondering on Stack Overflow See other posts from Stack Overflow or by Wondering
Published on 2010-03-21T17:36:36Z Indexed on 2010/03/21 17:41 UTC
Read the original article Hit count: 162

Filed under:
|

Hi All,

Through javascript I am appending one query parameter to the page url and I am facing one strange behaiviour

              <div>
                 <a href="Default3.aspx?id=2">Click me</a>
                </div>


             $(function () {

                 window.location.href = window.location.href + "&q=" + "aa";
        });

Now I am appending &q in default3.aspx and in this page the &q is getting added continuously I mean the url become http://localhost:1112/WebSite2/Default3.aspx?id=2&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa&q=aa

one would say just pass it like <a href="Default3.aspx?id=2&q=aa">Click me</a> but I cant do that , value of this query parameter is actually value of an html element which is in default3.aspx..I have to add it in run time.

what are the ways to achieve this. Thanks.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript