2013-03-15 1535 views
5

當Chrome顯示頁面「Error 106(net :: ERR_INTERNET_DISCONNECTED):Internet連接已丟失」時,是否有任何後臺擴展檢測到的問題。 ?我曾嘗試使用chrome.webRequest.onErrorOccurred.addListenerchrome.webNavigation.onErrorOccurred.addListener註冊偵聽器,但在發生「錯誤106」時都不會調用偵聽器。我的聽衆正在被正確調用以解決其他錯誤,例如「net :: ERR_NAME_NOT_RESOLVED」。檢測到「Error 106 net :: ERR_INTERNET_DISCONNECTED」)

我在Windows 7環境中針對Chrome 22.0.1229.94。更大的目標是在互聯網連接丟失時提供自定義消息(在單獨的選項卡中)。

+4

你試過了'navigator.onLine'財產和/或'window.ononline' /'窗口。 onoffline'事件呢? –

+0

羅布W,那些完美的工作。謝謝。 – trauble

+1

我真的不會相信navigator.onLine,因爲我發現很多情況下,它並不代表真正的互聯網連接,但更多地連接到本地網絡/路由器 –

回答

1

我個人結束了測試響應== 「」 和狀態== 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; 
+0

對於net :: ERR_CONNECTION_REFUSED和net :: ERR_INTERNET_DISCONNECTED都會發生這種情況,所以它不是非常有用,可悲的是 – Josh