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";
        }

 

 

posted @ 2008-08-27 10:17  吴碧宇  阅读(661)  评论(0编辑  收藏  举报