获取url中的参数

Posted on 2018-03-22 09:30  lianfeng  阅读(180)  评论(0编辑  收藏  举报
 
    function getRequest() {
        var url = window.location.search;
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] =     
                unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
 

Copyright © 2024 lianfeng
Powered by .NET 9.0 on Kubernetes