var strinfo
 function getAjax()
{
 var XmlHttp;
 
 //Creating object of XMLHTTP in IE
 try
  {
  XmlHttp = new ActiveXObject("Msxml4.XMLHTTP");
  }
 catch(e)
  {
   try
    {
     XmlHttp = new ActiveXObject("Msxml3.XMLHTTP");
    }
   catch(e)
    {
     try
      {
       XmlHttp = new
ActiveXObject("Msxml2.XMLHTTP");
      }
     catch(e)
      {
       try
        {
         XmlHttp = new

ActiveXObject("Microsoft.XMLHTTP");
        }
       catch(oc)
        {
         XmlHttp = null;
        }
      }
    }
  }
 //Creating object of XMLHTTP in Mozilla and Safari
 if(!XmlHttp && typeof XMLHttpRequest != "undefined")
 {
  XmlHttp = new XMLHttpRequest();
  if(XmlHttp.overrideMimeType)
  {
       XmlHttp.overrideMimeType("text/xml");
      }
 }
 return XmlHttp;
}
function  refreshh()   
{   
//5秒自动刷新一次,1秒取得一次数据.   

timer  =  window.setInterval("loadData()",5000);  

}   
<!-- 
function  loadData(){ 

 url = "message_new.aspx";
 req = getAjax();

 req.onreadystatechange = function(){
 
  if( req.readyState == 4 && req.status == 200 ) {
   strinfo = req.responseText;
   shownewmessage();
  }
 
 }
 
 req.open( 'GET', url, true );
 req.send( null );


}
function  shownewmessage(){  
document.all["labelnumber"].innerText ="您有 "+strinfo+" 条新消息";

}
// alert("系统提示:有新的消息,请及时查看!"); -->
 //  if(strinfo==1)
 //JavaScript Document
//<script type="text/javascript" >window.onload=refreshh();</script>//xxx.aspx文件调用

相关文章:

  • 2021-09-14
  • 2020-03-30
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
  • 2021-11-05
猜你喜欢
  • 2021-09-01
  • 2021-09-06
  • 2021-10-26
  • 2022-01-08
  • 2021-12-07
  • 2021-09-01
相关资源
相似解决方案