dhqz

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.在其他方法中就可以用了

分类:

技术点:

相关文章:

  • 2022-01-28
  • 2021-12-03
  • 2022-12-23
  • 2021-12-04
  • 2021-09-27
  • 2021-11-23
  • 2022-12-23
  • 2022-02-01
猜你喜欢
  • 2022-01-05
  • 2021-12-31
  • 2022-01-08
  • 2021-11-20
  • 2022-12-23
  • 2021-12-22
  • 2022-01-16
相关资源
相似解决方案