首页 > 代码库 > [snippet] get parameter

[snippet] get parameter

?
1
2
3
4
5
6
7
8
9
10
function(name)   
            {  
                    var query=location.search.substring(1); 
                    var pairs=query.split("&");  
                    for(var i=0;i<pairs.length;i++)  
                    {   var pos=pairs[i].indexOf(‘=‘); 
                            if(pos==-1)   continue;  
                            if(name==pairs[i].substring(0,pos)) {value=http://www.mamicode.com/pairs[i].substring(pos+1); return value;}
                    }return undefined;
            }