ASP.NET provides Request.QueryString collection that retrieves the values of the
variables in the HTTP query string, but there is no built-in mechanism to retrieve
query string collection on the client-side. However, you can parse the window
location search property to get the query string values by using the
GetAttributeValue method that we provided in one of our previous tips to center your
window. Note that window.location.search property gets or sets the substring of the
href property that follows the question mark.



function GetAttributeValue(attribList, attribName, firstDelim,
secondDelim)
{
var attribNameLowerCase = attribName.toLowerCase();
if (attribList)
{
var attribArr = attribList.split(firstDelim);
for (var i = 0, loopCnt = attribArr.length; i < loopCnt; i++)
{
var nameValueArr = attribArr[i].split(secondDelim);
for (var j = 0, loopCnt2 = nameValueArr.length; j < loopCnt2;j++)
{
if (nameValueArr[0].toLowerCase().replace(/\s/g, '') == attribNameLowerCase && loopCnt2 > 1)
{
return nameValueArr[1];
}
}
}
}
}

This method takes three arguments: a name/value pair list, the attribute name to
retrieve its value, the first delimiter and the second delimiter. The first delimiter will be ampersand and the second delimiter would be equal sign to parse query string variables. Then you can use the following method to retrieve the query string value for given query string variable name.



function GetQueryStringValue(varName)
{
return GetAttributeValue(window.location.search.substring(1),varName, '&', '=');
}