小弟好不容易做晚了,结果在ie上不能用,改怎么办啊,做的时候是用的火狐(主要是觉的他的调试不错)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="js/jquery.js" language="javascript" type="text/javascript"></script>
<script src="js/jquery.flot.pack.js" language="javascript" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><script src="js/ajax.js" language="javascript" type="text/javascript"></script>
<script src="js/test.js" language="javascript" type="text/javascript"></script><style type="text/css">
body{margin:0px auto;font-size:12px;}
.topnav{height:29px;background:#284C93;width:100%;
padding: 5px 10px; }
/*顶部导航*/
.topnav p span
{
background-color:#284C93;
border: 1px solid #CCCCCC;
cursor: pointer;
color:white;
width:104px;
height:27px;
display:block;
float:left;
line-height:27px;
text-align:center;
margin-right:4px;
margin-bottom:0px;
margin-top:-12px !important;
margin-top:4px;
border:1px solid #00236F;
}
.topnav p span a
{
height:27px;
line-height:27px;
display:block;
width:100%;
color:white;
text-decoration:none;
font-size:12px;
border:1px solid #4D6FAE;
letter-spacing:6px;
}
.topnav p span a.one
{
background:url(img/home.png) no-repeat 12px 2px;
}
.topnav p span a.two
{
background:url(img/shijian.png) no-repeat 12px 2px;
}
.topnav p span.current
{
background:url(img/tab_select_bg.jpg) center;
color:#053FC3;
font-weight:bold;
}
.topnav p span.current a
{
color:#053FC3;
font-weight:bold;
}
/*内容块*/
.content{}
.contentbox_title
{
background:url(img/tab_select_bg.jpg) center;
height:20px;
display:block;
border-bottom:1px solid #A0BED6;
color:#294D95;
font-weight:bold;
line-height:20px;
padding-left:14px;
}
.contentbox
{
background:#F6FAFF;
border:1px solid #A0BED6;
}
.jiaoyilian
{
/*width:400px;;
height:250px;
float:left;margin:12px;*/
}
.shiyonglv
{
/*width:100%;
height:250px;
margin:12px;float:right;*/
}
.tongji
{
margin:12px;
display:block;
height:250px;
}
/*第二个切换块*/
.tabtwo{}
dd{margin:0px;padding:0px;display:block;float:left;border:1px solid #CCCCCC;margin-right:4px;height:18px;width:80px;text-align:center;}
.selected{background:white;cursor:hand;}</style>
<script>
//到图
var arr = new Array();var arrDates = new Array();
$(document).ready(function() {
$(".topnav span:first").addClass("current"); //为第一个SPAN添加当前效果样式
$(".topnav span").mouseover(function() {
$(".topnav span").removeClass("current"); //去掉所有SPAN的样式
$(this).addClass("current");
}); //第二个tab切换
$(".tabtwo dd:first").addClass("selected"); //为第一个SPAN添加当前效果样式
$(".tongji ul:not(:first)").hide(); //隐藏其它的UL
$(".tabtwo dd").mouseover(function() {
$(".tabtwo dd").removeClass("selected"); //去掉所有SPAN的样式
$(this).addClass("selected");
$(".tongji ul").hide();
$("." + $(this).attr("id")).fadeIn('slow');
}); $(".jiaoyilian").css({width:"650px",height:"350px",float:"left",margin:"12px 12px 12px 6px"});
$(".shiyonglv").css({height:"250px",flat:"right",margin:"12px"});});
//时间源
function GetNowTime()//JS取时间
{ var dateNow=new Date();
alert(dateNow);
var daystoadd= -1;
var newtime=dateNow.getTime()+(daystoadd*24*60*60*1000);
var arrDate =new Array();
for(var i=0;i<24*60/5;i++){
var newtimems=0;
newtimems=newtime+(i*5*60*1000);
arrDate[i] = new Date( newtimems );
}
return arrDate;
}
// 获取业务数据--begin
//数据源
alert("error ");
arrDates=GetNowTime();
var d = [];//cos = [];
for (var i = 0; i < 288; i ++) {
d.push([new Date(arrDates[i]).getTime()+28800000, ( Math.sin(i)*100+i*100) ]);
}
$(function(){
var plotarea = $("#chart");
// plotarea.css("height", "250px");
//plotarea.css("width", "500px"); for (var i = 0; i < d.length; ++i)
var options = {
legend: {
show: true,
margin: 10,
backgroundOpacity: 0.5
},
points: {
show: false,
radius: 3
},
lines: {
show: true
},
xaxis : {
mode : "time",
// ticks:12, //12个格子
//timeformat:"%m/%d<br>%h:%M"},
ticks:24, //24个格子
timeformat:"%m/%d<br>%h:%M"},
selection: { mode: "x" },
};
var plot = $.plot($("#chart"), [d], options); //绑定图表
// now connect the two
$("#chart").bind("plotselected", function (event, ranges) { //使图标可以放大
// do the zooming
plot = $.plot($("#chart"), [d],
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
})); });
} ) $(function(){
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
})
</script>
</head><body>
<div class="topnav">
<p>
<span ><a href="#" class="one"> 首页</a></span> <span ><a href="#" class="two">事件</a></span> </p>
</div>
<div class="content">
<div class="contentbox jiaoyilian" >
<div class="contentbox_title">交易量</div>
<div id="chart" style="width:550px;height:260px;">
</div>
</div>
<div class="contentbox shiyonglv">
<div class="contentbox_title">使用率</div>
<div>
<table width="100%">
<thead>
<tr class="contentbox_title" >
<th>主机</th><th>CPU使用率</th><th>内存使用率</th><th>状态</th>
</tr>
</thead>
<tbody id="tbody1">
</tbody>
</table>
</div>
</div>
<div class="tabtwo">
<div class="contentbox tongji ">
<div class="contentbox_title">
<dd id="tab1">交易量统计</dd>
<dd id="tab2">交易错误统计</dd>
</div>
<ul class="tab1">
<li><a href="http://www.poluoluo.com" target="_blank">交易量统计a</a></li><li><a href="http://www.poluoluo.com" target="_blank">交易量统计b</a></li><li><a href="/jzxy/wytx/code/index.html" target="_blank">交易量统计c</a></li></ul>
<ul class="tab2">
<li><a href="/jzxy/wytx/menu/Index.html" target="_blank">交易错误统计1</a></li><li><a href="/jzxy/wytx/jscode/index.html" target="_blank">交易错误统计2</a></li></ul>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script src="js/jquery.js" language="javascript" type="text/javascript"></script>
<script src="js/jquery.flot.pack.js" language="javascript" type="text/javascript"></script>
<script language="javascript" type="text/javascript" src="../excanvas.min.js"></script><script src="js/ajax.js" language="javascript" type="text/javascript"></script>
<script src="js/test.js" language="javascript" type="text/javascript"></script><style type="text/css">
body{margin:0px auto;font-size:12px;}
.topnav{height:29px;background:#284C93;width:100%;
padding: 5px 10px; }
/*顶部导航*/
.topnav p span
{
background-color:#284C93;
border: 1px solid #CCCCCC;
cursor: pointer;
color:white;
width:104px;
height:27px;
display:block;
float:left;
line-height:27px;
text-align:center;
margin-right:4px;
margin-bottom:0px;
margin-top:-12px !important;
margin-top:4px;
border:1px solid #00236F;
}
.topnav p span a
{
height:27px;
line-height:27px;
display:block;
width:100%;
color:white;
text-decoration:none;
font-size:12px;
border:1px solid #4D6FAE;
letter-spacing:6px;
}
.topnav p span a.one
{
background:url(img/home.png) no-repeat 12px 2px;
}
.topnav p span a.two
{
background:url(img/shijian.png) no-repeat 12px 2px;
}
.topnav p span.current
{
background:url(img/tab_select_bg.jpg) center;
color:#053FC3;
font-weight:bold;
}
.topnav p span.current a
{
color:#053FC3;
font-weight:bold;
}
/*内容块*/
.content{}
.contentbox_title
{
background:url(img/tab_select_bg.jpg) center;
height:20px;
display:block;
border-bottom:1px solid #A0BED6;
color:#294D95;
font-weight:bold;
line-height:20px;
padding-left:14px;
}
.contentbox
{
background:#F6FAFF;
border:1px solid #A0BED6;
}
.jiaoyilian
{
/*width:400px;;
height:250px;
float:left;margin:12px;*/
}
.shiyonglv
{
/*width:100%;
height:250px;
margin:12px;float:right;*/
}
.tongji
{
margin:12px;
display:block;
height:250px;
}
/*第二个切换块*/
.tabtwo{}
dd{margin:0px;padding:0px;display:block;float:left;border:1px solid #CCCCCC;margin-right:4px;height:18px;width:80px;text-align:center;}
.selected{background:white;cursor:hand;}</style>
<script>
//到图
var arr = new Array();var arrDates = new Array();
$(document).ready(function() {
$(".topnav span:first").addClass("current"); //为第一个SPAN添加当前效果样式
$(".topnav span").mouseover(function() {
$(".topnav span").removeClass("current"); //去掉所有SPAN的样式
$(this).addClass("current");
}); //第二个tab切换
$(".tabtwo dd:first").addClass("selected"); //为第一个SPAN添加当前效果样式
$(".tongji ul:not(:first)").hide(); //隐藏其它的UL
$(".tabtwo dd").mouseover(function() {
$(".tabtwo dd").removeClass("selected"); //去掉所有SPAN的样式
$(this).addClass("selected");
$(".tongji ul").hide();
$("." + $(this).attr("id")).fadeIn('slow');
}); $(".jiaoyilian").css({width:"650px",height:"350px",float:"left",margin:"12px 12px 12px 6px"});
$(".shiyonglv").css({height:"250px",flat:"right",margin:"12px"});});
//时间源
function GetNowTime()//JS取时间
{ var dateNow=new Date();
alert(dateNow);
var daystoadd= -1;
var newtime=dateNow.getTime()+(daystoadd*24*60*60*1000);
var arrDate =new Array();
for(var i=0;i<24*60/5;i++){
var newtimems=0;
newtimems=newtime+(i*5*60*1000);
arrDate[i] = new Date( newtimems );
}
return arrDate;
}
// 获取业务数据--begin
//数据源
alert("error ");
arrDates=GetNowTime();
var d = [];//cos = [];
for (var i = 0; i < 288; i ++) {
d.push([new Date(arrDates[i]).getTime()+28800000, ( Math.sin(i)*100+i*100) ]);
}
$(function(){
var plotarea = $("#chart");
// plotarea.css("height", "250px");
//plotarea.css("width", "500px"); for (var i = 0; i < d.length; ++i)
var options = {
legend: {
show: true,
margin: 10,
backgroundOpacity: 0.5
},
points: {
show: false,
radius: 3
},
lines: {
show: true
},
xaxis : {
mode : "time",
// ticks:12, //12个格子
//timeformat:"%m/%d<br>%h:%M"},
ticks:24, //24个格子
timeformat:"%m/%d<br>%h:%M"},
selection: { mode: "x" },
};
var plot = $.plot($("#chart"), [d], options); //绑定图表
// now connect the two
$("#chart").bind("plotselected", function (event, ranges) { //使图标可以放大
// do the zooming
plot = $.plot($("#chart"), [d],
$.extend(true, {}, options, {
xaxis: { min: ranges.xaxis.from, max: ranges.xaxis.to }
})); });
} ) $(function(){
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
})
</script>
</head><body>
<div class="topnav">
<p>
<span ><a href="#" class="one"> 首页</a></span> <span ><a href="#" class="two">事件</a></span> </p>
</div>
<div class="content">
<div class="contentbox jiaoyilian" >
<div class="contentbox_title">交易量</div>
<div id="chart" style="width:550px;height:260px;">
</div>
</div>
<div class="contentbox shiyonglv">
<div class="contentbox_title">使用率</div>
<div>
<table width="100%">
<thead>
<tr class="contentbox_title" >
<th>主机</th><th>CPU使用率</th><th>内存使用率</th><th>状态</th>
</tr>
</thead>
<tbody id="tbody1">
</tbody>
</table>
</div>
</div>
<div class="tabtwo">
<div class="contentbox tongji ">
<div class="contentbox_title">
<dd id="tab1">交易量统计</dd>
<dd id="tab2">交易错误统计</dd>
</div>
<ul class="tab1">
<li><a href="http://www.poluoluo.com" target="_blank">交易量统计a</a></li><li><a href="http://www.poluoluo.com" target="_blank">交易量统计b</a></li><li><a href="/jzxy/wytx/code/index.html" target="_blank">交易量统计c</a></li></ul>
<ul class="tab2">
<li><a href="/jzxy/wytx/menu/Index.html" target="_blank">交易错误统计1</a></li><li><a href="/jzxy/wytx/jscode/index.html" target="_blank">交易错误统计2</a></li></ul>
</div>
</div>
</div>
</body>
</html>
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
})我想搞个循环下面是test.js,setInterval(
function(){
$.ajax({type : "POST",
url : "information.xml",
dataType:($.browser.msie) ? "text" : "xml",
success : function(xml) {
if( typeof xml == "string" ){
var oxml = new ActiveXObject("Microsoft.XMLDOM");
oxml.async = false;
oxml.loadXML(xml);
xml = oxml;
}
// arrDates=GetNowTime();//此处
//alert(arrDates[287]);
alert($(xml).find("computer").length);
$(xml).find("computer").each(function() {
var computer = $(this);
var host = computer.find("host").text();
var cpuUtilityRate = computer.find("cpuUtilityRate").text();
var MemoryUtilityRate = computer.find("MemoryUtilityRate").text();
var Condition = computer.find("Condition").text();
var str= "<tr><td>"+host+"</td><td>"+cpuUtilityRate+"</td><td>"+MemoryUtilityRate+"</td><td>"+Condition+"</td>"
$("#tbody1").append(str);
arr.push(computer );
})
},
error : function(xml) {
alert(xml.responseText);
//alert("error loading xml");
}
});
}
,1000*60*5)// arrDates=GetNowTime();
我想自动调用的时候取个时间,但是取时间的方法GetNowTime()是写在html里面的,arrDates是html的全局变量,有什么办法呀
那么调用html里的方法是没有问题的啊
不过你最好把.js文件引用放在arrDates定义的后面~
1<script src="js/test.js" language="javascript" type="text/javascript"></script>//导入
function GetNowTime()//申明全局变量
2 定义function GetNowTime()//JS取时间
3调用test.js,
$(function(){
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
4test.js里调用
function{
arrDates=GetNowTime();//此处出错,错误: 缺少对象
}
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
})能通过引用添加进来么·
$(function(){
$.ajax({
type: "GET",
url: "js/test.js",
dataType: "script"
});
})是用来调用test.js的呀
在test.js写了个动态ajax