title: How can I define if my pc has access to internet with javascript?
body: <p>I am developing an chrome extension application, and I am using this javascript to check if users are connected to any Network.<br>
  var statusElem = document.getElementById('status');</p>
  
  <pre><code>var intervalId = setInterval(function () {
    if (navigator.onLine) {
      // clear the interval
      clearInterval(intervalId);
  
      // you're online. Redirect to the desired URL
      window.location = "popup.html";
    }
    else {
      statusElem.className = 'offline';
      statusElem.innerHTML = '&lt;span style="color: red"&gt;Connect your device to internet&lt;/span&gt;';
    }
  }, 500);
  </code></pre>
  
  <p>But it doesen't check if the network connection has access to internet, is there anyway to check if we are sending or receiving data from internet?</p>