方法一:(仅适用于ie)
function CheckStatus(url)
{
XMLHTTP = new ActiveXObject("Microsoft.XMLHTTP")
XMLHTTP.open("HEAD",url,false)
XMLHTTP.send()
return XMLHTTP.status==200
} function NetPing()
{
return CheckStatus("http://www.163.com/index.html");
}
方法二:(利用jquery,适用所有浏览器)
function NetPing() {
$.ajax({
type: "GET",
cache: false,
url: "http://www.163.com/index.html",
data: "",
success: function() {
Done(1);
},
error: function() {
Done(0);
}
}); }