js获取url地址?后面参数

let url = window.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]);
}
}
console.log(theRequest)
posted @ 2018-12-22 14:59  码路上的奋斗  阅读(3011)  评论(0编辑  收藏  举报