检测网站能否被正常访问

var   xmlHttp;
function   createXMLHttpRequest()  
{  
if   (window.ActiveXObject)  
{  
          xmlHttp   =   new   ActiveXObject( "Microsoft.XMLHTTP ");  
}  
else   if   (window.XMLHttpRequest)
{  
          xmlHttp   =   new   XMLHttpRequest();   }  
                  }  

function   startRequest()  
{  
createXMLHttpRequest();  
xmlHttp.onreadystatechange   =   handleStateChange;  
xmlHttp.open( "GET ",   "http://www.abcde.com/ ",   true);  
xmlHttp.send(null);  
}  
function   handleStateChange()  
{  
if(xmlHttp.readyState   ==   4)  
{  
if(xmlHttp.status   ==   200)  
{  


  }  

}
else
{
}
}

可以用HttpWebRequest判断返回的Http_Code
根据HTTP协议非200就是非正常状态

猜你喜欢

转载自blog.csdn.net/kellysir/article/details/4388463