We can easily set up a Javascript function that will retrieve the query string and load an array with the values passed in the query string. Here it is. This function goes into the head section of our page.
var qsParm;
GetQueryStringParams();
function GetQueryStringParams() {
//Holds key:value pairs
qsParm = new Array();
//Get querystring from url
var requestUrl =
window.location.search.toString();
if (requestUrl != '')
{
//window.location.search returns the part of the
URL
//that follows the ? symbol, including the ? symbol
var query = requestUrl.substring(1);
//Get key:value pairs from querystring
var parms = query.split('&');
for (var i = 0;
i < parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0, pos);
var val = parms[i].substring(pos + 1);
qsParm[key] = val;
}
}
}
}
1 comment:
Great Information.it was very much useful.
Thanks for posting such a article.
keep sharing.
Post a Comment