LISTEN FOR ONLINE AND OFFLINE EVENTS

When you have two levels of connectivity detection, browser online and offline — which is typically physical media connectivity or in-browser online/offline mode — and network online and offline — which is the actual access online to your web server — you can begin modifying your web application to react properly to both groups of online and offline events:

addEventListener('online', function(){
   // The browser has come online.
 }, false);
 addEventListener('offline', function(){
   // The browser has gone offline.
 }, false);
 addEventListener('netonline', function(){
   // The network has come online.
}, false);
 addEventListener('netoffline', function(){
   // The network has gone offline.
}, false);

Considering that ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.