Skip to content

Instantly share code, notes, and snippets.

@antunesleo
Created April 26, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antunesleo/c0f435e8ee706728e49ae3a21125c030 to your computer and use it in GitHub Desktop.
Save antunesleo/c0f435e8ee706728e49ae3a21125c030 to your computer and use it in GitHub Desktop.
window.addEventListener('load', function(e) {
if (navigator.onLine) {
console.log('We\'re online!');
} else {
console.log('We\'re offline...');
}
}, false);
window.addEventListener('online', function(e) {
console.log('And we\'re back :).');
}, false);
window.addEventListener('offline', function(e) {
console.log('Connection is down.');
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment