Click here to Skip to main content
15,880,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hii all
i have asp.net page which passes a querystring to another page.
i want to check about that querystring but in javasript.

$(document).ready.

Any Suggestion......

Thanks
Posted

C#
unction getQuerystring(key)

{



 key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,\\\]);

 var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");

 var qs = regex.exec(window.location.href);

 if(qs == null)

alert("SOme message");

else alert(qs[1]);

}
 
Share this answer
 
Hey Dude..

You can get & extract the query string in JavaScript using the following Lines.



C#
var qrStr = window.location.search;
    qrStr = qrStr.split("?")[1].split("=")[1];



Hope this
will help...:)
 
Share this answer
 
pl check the following link for different options:

http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript[^]
 
Share this answer
 
Comments
moon2011 25-Aug-11 8:39am    
thanks, but i saw it before and i couldn't get it. :)
Get_Query_String_Using_Javascript[^]

JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript[^]

I got about 1.35 million results by using "Javascript Querystring" as a search term in google.
Check them out[^]
 
Share this answer
 
I found a very clear/simple and working solution.

Go through the link below -
accessing querystring through javascript
 
Share this answer
 
You cold refer this article, which provides the solution: Easy Manipulation of URL in JavaScript[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900