Saturday, December 29, 2007

JavaScript: Request.Querystring equivalent

// ***
// Equivalent of C# Request.QueryString[key]
// ***
function getQueryString(key, query)
{
//query = parent.location.search;e

if (query.length > 1)
{
query = query.substring(1, query.length);
for(var i=0; i < query.split("&").length; i++)
{
subQuery = query.split("&")[i];
subQueryKey = subQuery.split("=")[0];
subQueryValue = subQuery.split("=")[1];
if (subQueryKey.toLowerCase()==key.toLowerCase())
{
return subQueryValue;
}
}
}
else
{
return null;
}
return null;
}

No comments:

Post a Comment

Please use your common sense before making a comment, and I truly appreciate your constructive criticisms.