js 读取URL参数
var p = new ParamManager();
p.GetValue('key');
function ParamManager()
{
this.Location = window.location;
this.ParamArray = new Array();
this.onInit();
}
ParamManager.prototype.onInit=function(){
var l = new String(this.Location);
var paramstring = new String(l.substring(l.lastIndexOf('?')+1,l.length));
this.ParamArray = paramstring.split('&');
for(var i = 0;i<this.ParamArray.length;i++)
{
this.ParamArray[i] = this.ParamArray[i].toString().split('=');
}
}
ParamManager.prototype.GetValue=function(key){
for(var i=0;i<this.ParamArray.length;i++)
{
if(this.ParamArray[i][0] == key)
{
return this.ParamArray[i][1];
}
}
return "null";
}
{
this.Location = window.location;
this.ParamArray = new Array();
this.onInit();
}
ParamManager.prototype.onInit=function(){
var l = new String(this.Location);
var paramstring = new String(l.substring(l.lastIndexOf('?')+1,l.length));
this.ParamArray = paramstring.split('&');
for(var i = 0;i<this.ParamArray.length;i++)
{
this.ParamArray[i] = this.ParamArray[i].toString().split('=');
}
}
ParamManager.prototype.GetValue=function(key){
for(var i=0;i<this.ParamArray.length;i++)
{
if(this.ParamArray[i][0] == key)
{
return this.ParamArray[i][1];
}
}
return "null";
}