Detection "Error 106 net :: ERR_INTERNET_DISCONNECTED" "

Is there a way to detect in the background extension when Chrome shows the page "Error 106 (net :: ERR_INTERNET_DISCONNECTED): Internet connection lost."? I tried registering a listener with chrome.webRequest.onErrorOccurred.addListener and chrome.webNavigation.onErrorOccurred.addListener , but no listeners are called when "Error 106" occurs. My listeners are correctly called for other errors, such as "net :: ERR_NAME_NOT_RESOLVED".

I am targeting Chrome 22.0.1229.94 in Window 7. The bigger goal is to provide custom messages (on a separate tab) when I lose connectivity to the Internet.

+6
source share
1 answer

I personally finished testing for the answer == "" and 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; 
+1
source

All Articles