JS获取URL后面的参数
仅作为Shane个人笔记
没啥好说的
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;
- Shane在B站的TP6视频
- 用ThinkPHP6制作后台