<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head> <Title> PHP + Ajax real-time automatic detection of networking </title> <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"> <Script type = "text/javascript"> <! -- Var xmlHttp; Function createXMLHttpRequest (){ If (window. ActiveXObject ){ XmlHttp = new ActiveXObject ("Microsoft. XMLHTTP "); } Else if (window. XMLHttpRequest ){ XmlHttp = new XMLHttpRequest (); } } Function start (){ CreateXMLHttpRequest (); Var url = "getNetLink "; XmlHttp. open ("GET", url, true ); XmlHttp. onreadystatechange = callback; XmlHttp. send (null ); } Function callback (){ If (xmlHttp. readyState = 4 ){ If (xmlHttp. status = 200 ){ Document. getElementById ("shownetlink"). innerHTML = xmlHttp. responseText; SetTimeout ("start ()", 8000 ); } } } // --> </Script> </Head> <Body onload = "start ();"> <H1> PHP + Ajax real-time automatic detection of networking <P> current network status: <span id = "shownetlink"> </span> </p> </Body> </Html> |