Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
  <head>
  <title>Offline/Online event toggling demo</title>
  <script>
      var online = function () {
        logger("<B>online</B>");
      }
      var offline = function () {
        logger("offline");
      }
      var logger = function (status){
        var log = document.getElementById('log');
        console.log(status);
        log.innerHTML += "<br>" + status + " :: navigator.onLine:" + navigator.onLine + " :: " + new Date();
      }
      window.addEventListener('online',  online);
      window.addEventListener('offline', offline);
      console.log('listening for online/offline effects');
</script>
</head>
<h1>listening for online/offline effects</h1>
<input type="button" value="poll network status" onclick="javascript:logger('<i>checking status</i>');">
<div id="log">
</div>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers