[JS]How to get url params

2015-10-29 写技术

How to get url params?

 

function GetUrlParams(){
    var args=new Object();  
    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;  
            var argname=pairs[i].substring(0,pos);  
            var value=pairs[i].substring(pos+1);  
            args[argname]=unescape(value);  
    }
    return args;
}

标签: JS

发表评论:

Powered by anycle 湘ICP备15001973号-1