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.οnlοad=refreshh();</script>//xxx.aspx文件调用 //获得的message_new.aspx的内容最好用this.Response.Write("")写出来
