Note: Please check JavaScript Utility Functions Note.

The following two functions will allow you to extract a specified parameter from the URL.
To be more precise, only the first one will extract it automatically from the URL, the second function, which is an extension of the first one, will extract the specified parameter value from user defined source which is passed as a parameter.


/*Define the namespaces*/
var JavaScript = {};
JavaScript.Utils = {};
JavaScript.Utils.URL = {};

JavaScript.Utils.URL.GetURLParam = function(param) {
param = param.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + param + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);

if (results == null)
return "";
else
return results[1];
};


JavaScript.Utils.URL .GetUrlParamEx = function(source, name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(source);
if (results == null)
return "";
else

return results[1];
};