如何获取url上面的参数

例如 :网页.html?id=0 

//获取url中"?"符后的字串  go
function getRequest() {
var url = window.location.search;
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var 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'];
console.log(id);
原文地址:https://www.cnblogs.com/qiuchuanji/p/7659305.html