Elegant way of retrieving query string parameter.

Posted by Wondering on Stack Overflow See other posts from Stack Overflow or by Wondering
Published on 2010-03-08T09:12:54Z Indexed on 2010/03/08 9:21 UTC
Read the original article Hit count: 374

Filed under:
|

Hi All, I am retrieving one query string parameter, and for that my code is

 <a href="Default2.aspx?Id=1&status=pending&year=2010">Click me</a>

Now I want to retrieve "status=pending" and for that I am doing

 var qString = window.location.search.substring(1);
                  var Keys = qString .split('&');
                 alert(Keys[1]);

This works fine, but I am hard-coding [1] here. is there any elegent way of doing this without hard-coding?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery