Answers for "window.addEventListener("online");"

0

window.addEventListener("online");

window.addEventListener('load', function() {
  var status = document.getElementById("status");
  var log = document.getElementById("log");

  function updateOnlineStatus(event) {
    var condition = navigator.onLine ? "online" : "offline";

    status.className = condition;
    status.innerHTML = condition.toUpperCase();

    log.insertAdjacentHTML("beforeend", "Event: " + event.type + "; Status: " + condition);
  }

  window.addEventListener('online',  updateOnlineStatus);
  window.addEventListener('offline', updateOnlineStatus);
});
Posted by: Guest on August-16-2020

Code answers related to "window.addEventListener("online");"

Code answers related to "Javascript"

Browse Popular Code Answers by Language