Home  /  Questions  /  Question

113   96.7
Apr 12, 2011

How to retrieve specific Name/Value pairs from Querystring in Javascript?

What is the best way to retrieve specific name/value pairs in Javascript from the Querystring?
For example if the url is "http://www.mycompany.com/customer/orders.aspx?id=1&name=john&address=main"
and I need the value for the id say.

Ideally I am looking for either a jQuery or else non-library solution (i.e. raw Javascript).


1,364   100.0
Apr 16, 2011
Thought of writing this down, but here a great deal of solutions...


Also a jQuery plugin is available for the same.

It's simple as using below...
.query.get('name'); // The site has the required docs..