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";
        }
原文地址:https://www.cnblogs.com/wubiyu/p/1277371.html