js获url后的参数

function GetRequest() {
let url = location.href; //获取url中"?"符后的字串
let theRequest = {};
if (url.indexOf('?') != -1) {
let str = url.substr(url.indexOf('/?') + 2);
let strs = str.split('&');
for(let i = 0; i < strs.length; i ++) {
theRequest[strs[i].split('=')[0]]=unescape(strs[i].split('=')[1]);
}
}
return theRequest;
}
let request = GetRequest();
console.log(request['i_code'])
上一篇:第七届河南省赛A.物资调度(dfs)


下一篇:MongoDB学习笔记系列