下面是接收传参的代码:
方法一:
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r !== null) return unescape(r[2]);
return null;
}
var type = getQueryString('type');
方法二:
function getUrlPars(){
var url = location.search;
var theRequest = new Object();
if(url.indexOf("?")!=-1){
var str = url.substr(1);
strs = str.split("&");
for(var i=0;i<strs.length;i++)
{
var sTemp = strs[i].split("=");
theRequest[sTemp[0]]=(sTemp[1]);
}
}
return theRequest;
}
getUrlPars()['aid'],
希望可以帮到你!