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 ()
{
// Automatically refresh once every 5 seconds and obtain data once every 1 second.
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 = "you have" + strinfo + "New message ";
}
// Alert ("system prompt: there is a new message. Please check it in time! "); -->
// If (strinfo = 1)
// JavaScript document
// <SCRIPT type = "text/JavaScript"> window. onload = refreshh (); </SCRIPT> // call the XXX. aspx File
// It is best to use this. response. Write ("") to get the message_new.aspx content.