获取地址栏参数

发布时间 2023-11-07 08:39:48作者: 巳蛇

//获取地址栏参数
var url = window.location.search; //获取url中"?"符后的字串
console.log(url,'url')
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
console.log(str, 'str ')
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {

theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);

}
}


console.log(theRequest,'theRequest')