第一种方法:
(获取一个)
detail.html?order_id=10
<Script language="javascript">
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]]=unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
</script>
调取
$(document).ready(function(){
var a=GetRequest();
var order_id = a['order_id'];
// console.log(order_id)
Detail(order_id);
})
获取两个的(仔细看差别)
detail.html?order_id=10?uid=3
function GetRequest() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("?");
console.log(strs)
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
}
}
return theRequest;
}
调用
$(document).ready(function(){
var a=GetRequest();
var order_id = a['order_id'];
var uid = a['uid'];
// console.log(order_id)
//console.log(uid)
Detail(order_id,uid);
})
其他方法参见下面这篇博客
https://www.cnblogs.com/karila/p/5991340.html