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;
原文地址:https://www.cnblogs.com/hua-nuo/p/12858369.html