Retrieve Query String parameters

dshrenik
dshrenik used Ask the Experts™
on
How can I retrieve query string parameters from my javascript code?

If possible, please provide some sample code.
Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014
Commented:
If you meant the Current URL query string parameters, then you just have to do

var queryString = location.search;

var keyPairsCombined = queryString.split("&");
var keyPairMap = new Array();

for ( var counter = 0; counter < keyPairsCombined.length; counter++)
{
   var keyPair = keyPairsCombined[ counter ].split("=");
   keyPairMap[ keyPair[ 0 ] ] = keyPair[ 1 ];
}

now just mention the name like
alert(keyPairMap.name);
Kiran SonawaneProject Lead
Top Expert 2011
Commented:
This link has number of ways to extract the query strings

http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial