//代码的具体实现
function GetRequest() {
var url = location.search; //获取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]] = decodeURI(strs[i].split("=")[1]);
}
}
return theRequest;
}
//调用
var Request = new Object();
Request = GetRequest();
//用数组的方式获取
var id = Request["id"];
JS截取地址栏中的URL参数
最新推荐文章于 2023-03-06 16:43:42 发布