Get QueryString values in JavaScript

How to get QueryString values in JavaScript and jQuery?

For. Example:


Here, How to get the value of ‘orderid’ in your client side scripts like JavaScript or jQuery? In ASP.NET you can use Request.QueryString[“orderid”] to retrieve the query string values from URL.

Please use the following method.


function getQuerystring(param, default_) {
if (default_ == null) default_ = "";
param= param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + param + "=([^&#]*)");
var qsValue = regex.exec(window.location.href);
if (qsValue  == null)
return default_;
return qsValue [1];


var _orderProductRecordID = getQuerystring('orderId');


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s