How to get query string value in javascript
Hi Friends,
Few days ago I need to get the query string value at client
side in my application then I got a java script method via searching which returns the query
string value.
You just pass the name of the parameter name to the method.
Here I am placing the method.
<script type="text/javascript">
function getQuerystring(key, default_) {
if (default_ == null) default_ = "";
key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
var qs = regex.exec(window.location.href);
if (qs == null)
return default_;
else
return qs[1];
}
</script>
you just get the query string value like this
var paraValue=getQuerystring(key, 'ParaName') ;
Hope this will help you...
Rajesh
0 comments: