实现从一个页面带着某个数据传输到下一个页面,下一页面根据此数据进行一些处理。
从a.html跳转到b.html
a.html跳转代码
<a href='b.html?daka_id="+pbId+"' target='main'>跳转</a>
b.html取出a.html传来的数据(js代码)
var daka_id;//a.html传来的数据
$(function () {
var a = GetRequest();
daka_id = a['daka_id'];
//取a.html传来的所有参数
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]] = decodeURIComponent(strs[i].split("=")[1]);
}
}
return theRequest;
}
});