JS获取URL后面的参数

    var url = location.search;
    url = decodeURI(url);
    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]);
        }
    }
    //url后传递的参数
    var id = theRequest.id;
posted @ 2020-05-09 16:11  华诺  阅读(1058)  评论(0编辑  收藏  举报