I am trying to write an extension that will cache page content for offline reading. If the user activates the extension's popup while offline, I would like to show the cached content. Currently, I am thinking I can make an ajax request and wait to see if it fails, but if there is a part of the chrome API that would let me do this more quickly, that would be ideal.
I have done some googling and haven't come across anything.
if (navigator.onLine) {
// Online
} else {
// Offline
}
It also supports event listeners.
https://developer.mozilla.org/en/Online_and_offline_events
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With