Skip to content

Instantly share code, notes, and snippets.

@voigt
Created April 18, 2013 21:51
Show Gist options
  • Save voigt/5416524 to your computer and use it in GitHub Desktop.
Save voigt/5416524 to your computer and use it in GitHub Desktop.
Function that checks Online/Offline Status of Client
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