当Chrome显示页面"Error 106 (net::ERR_INTERNET_DISCONNECTED):网络连接已丢失“时,在后台扩展中有什么方法可以检测到吗?我已经尝试使用chrome.webRequest.onErrorOccurred.addListener和chrome.webNavigation.onErrorOccurred.addListener注册一个侦听器,但当出现"Error 106“时,这两个侦听器都没有被调用。对于其他错误,如"net::ERR_NAME_NOT_RESOLVED“,我的侦听器也被正确调用。
我的目标是Windows7环境下的Chrome 22.0.1229.94。更大的目标是在Internet连接丢失时提供自定义消息传递(在单独的选项卡中)。
发布于 2015-05-01 05:59:55
我个人最终测试了response == "“和status == 0。
var req = new XMLHttpRequest();
req.open("post", VALIDATE_URL, true);
req.onreadystatechange = function receiveResponse() {
if (this.readyState == 4) {
if (this.status == 200) {
console.log("We go a response : " + this.response);
} else if (!isValid(this.response) && this.status == 0) {
console.log("The computer appears to be offline.");
}
}
};
req.send(payload);
req = null;https://stackoverflow.com/questions/15433598
复制相似问题