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+" 条新消息";
}