页面间跳转的时候通过url传递一些参数,如何获取这些参数如下:
url:list/import.html?tableId='+tableId+'&v='+(new Date()).getTime()
/* 获取URL参数 */
var request = GetRequest();
console.log(request.tableId);
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;
}