基于XMLHttpRequest的文档:function returnStatus(req, status) { //console.log(req); if(status == 200) { console.log("The url is available"); // send an event } else { console.log("The url returned status code " + status); // send a different event }}function fetchStatus(address) { var client = new XMLHttpRequest(); client.onreadystatechange = function() { // in case of network errors this might not give reliable results if(this.readyState == 4) returnStatus(this, this.status); } client.open("HEAD", address); client.send();}fetchStatus("/");但是,这仅适用于与当前URL位于同一域中的URL。您想要能够ping外部服务吗?如果是这样,您可以在服务器上创建一个简单的脚本,为您完成工作,并使用javascript来调用它。