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'])
标签:theRequest,url,GetRequest,js,strs,let,split,参数 来源: https://www.cnblogs.com/anans/p/15263694.html