爱编程的老刀

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
头部
header("Content-Type: text/html; charset=gb2312");
header("Cache-Control: no-store, no-cache,must-revalidate"); 


js:

<html>
 
<head>
 
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
  
<script>
var req;

function Initialize()
{
 
try
 {
  req
=new ActiveXObject("Msxml2.XMLHTTP");
 }
 
catch(e)
 {
  
try
  {
   req
=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
catch(oc)
  {
   req
=null;
  }
 }

 
if(!req&&typeof XMLHttpRequest!="undefined")
 {
  req
=new XMLHttpRequest();
 }
 
}

function SendQuery(key)
{
 Initialize();
 
//key=Math.random();
 var url="http://staff.now.nxt.cn/vhost/monitor.php?k="+key;
 
 
if(req!=null)
 {
  req.onreadystatechange 
= Process;
  req.open(
"GET", url, true);
        req.send(
null);
        
 }
 
}

function Process()
{
 
if (req.readyState == 4
        {
        
// only if "OK"
   if (req.status == 200
   {
    
if(req.responseText=="")
     HideDiv(
"autocomplete");
    
else
    {
     ShowDiv(
"autocomplete");
     document.getElementById(
"autocomplete").innerHTML =req.responseText;
    }
   }
   
else 
   {
    document.getElementById(
"autocomplete").innerHTML="There was a problem retrieving data:<br>"+req.statusText;
   }
  }
}

function ShowDiv(divid) 
{
   
if (document.layers) document.layers[divid].visibility="show";
   
else document.getElementById(divid).style.visibility="visible";
}

function HideDiv(divid) 
{
   
if (document.layers) document.layers[divid].visibility="hide";
   
else document.getElementById(divid).style.visibility="hidden";
}

function BodyLoad()
{
 
//HideDiv("autocomplete");
 //document.form1.keyword.focus();
 //setTimeout("SendQuery('test')",5000);
 setInterval("SendQuery('test')",5000);
 
}
</script>
 
<style type="text/css"> 
  <!-- 
  .box 
{ border: 1px solid #000000; }
  .heading 
{
   font-family
: Georgia, "Times New Roman", Times, serif;
   font-weight
: bold;
   font-size
: 24px;
  
}
  .style1 
{color: #0033FF}
  .style2 
{color: #CC0066}
  .style3 
{color: #CC0000}
  .style4 
{color: #33CCCC}
  .style6 
{color: #669900}
  .style7 
{color: #FF0066}
  .style8 
{color: #FF6600}
  -->
 
</style>
 
<title>服务器监控页面</title></head>
 
<body onload="BodyLoad();">
  
<form name="form1">
  
<center>
   
<input name="keyword" onKeyUp="SendQuery(this.value)" style="WIDTH:700px" autocomplete="off" style="display:none">
   
<div align="left" class="box" id="autocomplete" style="WIDTH:700px;BACKGROUND-COLOR:#ccccff">读取数据中</div>
  
</center>
  
</form>
     
<align="center">&nbsp;</p>
 
</body>
</html>

posted on 2005-12-16 18:01  爱编程的老刀  阅读(187)  评论(0编辑  收藏  举报