Last active
August 29, 2015 14:05
-
-
Save pazguille/293498a69c6365321a15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function offline() { | |
document.body.innerHTML = 'You are offline :('; | |
} | |
function online() { | |
document.body.innerHTML = 'You are online :)'; | |
} | |
window.addEventListener('load', function(e) { | |
if (navigator.onLine) { | |
online(); | |
} else { | |
offline(); | |
} | |
}, false); | |
if (window.addEventListener) { | |
window.addEventListener('offline', offline); | |
window.addEventListener('online', online); | |
} else { | |
document.body.attachEvent('onoffline', offline); | |
document.body.attachEvent('ononline', online); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment