html页面传递参数
只是学习记录!望各位指教!
1.在第一个html页面以这种传过去

2.传到新页面也就是zabbixFlowEchart.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++) {
if(strs[i].split("=").length >2 ){
for(var j = 1;j<strs[i].split("=").length;j++){
if(j==1){
theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[j]);
}else{
theRequest[strs[i].split("=")[0]]=theRequest[strs[i].split("=")[0]]+"="+(strs[i].split("=")[j]);
}
}
}else{
theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
}
}
}
return theRequest;
}
3.解析完之后,初始化页面时统一拿到值
$(function(){
var Request = new Object();
Request = GetRequest();
var from,to,hostName,portName,key,to_k,name,type;
from = Request["from"].replace("%20"," ");//时间要处理一下
to = Request["to"].replace("%20"," ");
hostName = Request["hostName"];
portName = Request["portName"];
key=Request["key"];
to_k=Request["to_k"];
name = Request["name"];
type = Request["type"];
gethosts(hostName,key,to_k,portName,from,to);
// loadEchart(hostName,portName,from,to,name,type);
});
4.在其他方法中就可以用了
浙公网安备 33010602011771号