Created
April 18, 2013 21:51
-
-
Save voigt/5416524 to your computer and use it in GitHub Desktop.
Function that checks Online/Offline Status of Client
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 updateStatus () { | |
var textStaus = navigator.onLine ? "online" . "offline" | |
document.getElementById("status").innerHTML = textStatus; | |
if (navigator.onLine) { | |
document.body.classList.remove("offline"); | |
} else { | |
document.body.classList.add("offline"); | |
} | |
} | |
window.addEventListener("online", updateStatus); | |
window.addEventListener("offline", updateStatus); | |
updateStatus(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment