How to detect network state changes in a Chrome extension
问题 I'm writing a simple Chrome extension, the behavior is needed to detect if device is connect to the Internet. I'm currently trying to connect to ping service for checking network status and it is not efficient. Is there any event to which I can listen from Chrome JavaScript API? 回答1: There is no specific event in the Chrome extension APIs intended to be used for this purpose. In "How to detect online/offline event cross-browser?" it is suggested that you can use window.navigator.onLine and