Here, I am going to share Javascript code to get the URL querystring parameter values.
Let me take a sample URL and try to get the parameter values in it.
http://www.techtricky.com?id=77&name=sree
Here is the function to create the Javascript object with parameter names and values.
function getUrlParams() {
var params = {};
window.location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) {
params[key] = value;
});
return params;
}
In the above code, “window.location.search” is to get the query string, “replace” function and regular expression is to parse and save the parameters in the object.
Get the variables by calling above function:
var params = getUrlParams(); alert(params.id); alert(params.name);
Sometimes you might need to access the hash variables in the URL, below is the code for that:
var hash = window.location.hash;
Below is the code to set the hash variable for existing URL:
window.location.hash = "#top";

May 29th, 2011
admin
Posted in
Tags: 

Another way to find out..
http://jquerybyexample.blogspot.com/2012/05/how-to-get-querystring-value-using.html
thanks
just what i need
Thanks for this easy tip
.Save my Time
rgds,
Sandeep.K
Saved my Time, Thanks for the Tip