Offline events.

The user might be online
The user is offline

Code

window.ononline = function() {
  console.log("User **might** be online");
  var container = document.getElementById("container");
  container.className = "online";
};

window.onoffline = function() {
  console.log("User *is* offline");
  var container = document.getElementById("container");
  container.className = "offline";
};