js获取url后带的参数

    function GetRequest() {  
        var url = location.search; 
        var theRequest = new Object();  
        if (url.indexOf("?") != -1) {  
           var str = url.substr(1);  
           strs = str.split("&");  
           for(var i = 0; i < strs.length; i ++) {  
              theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);  
           }  
        }  
        return theRequest;  
     }  

 

posted @ 2018-02-28 19:10  大厨的笔记  阅读(1028)  评论(0编辑  收藏  举报