Created
October 25, 2012 11:44
-
-
Save netsi1964/3952154 to your computer and use it in GitHub Desktop.
Using jQuery add online status class to body
This file contains hidden or 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 setConnectionStatus(cStatus) { | |
jQuery('body').removeClass('online offline').addClass((navigator.onLine) ? 'online' : 'offline'); | |
} | |
window.addEventListener('online', setConnectionStatus, false); | |
window.addEventListener('offline', setConnectionStatus, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment