title: How to check for internet connection without having to refresh my whole page
body: <p>I want the following function to be called every x seconds, so I don't have to refresh my page.</p>
  
  <pre><code>var rq = new XMLHttpRequest();
  rq.open('GET', "SAME DOMAIN ADDRESS", true);
  rq.onreadystatechange = function() {
      if(rq.readyState === 4) {
          if(rq.status === 200) {
        clearTimeout(xmlHttpTimeout); 
  window.location.href = "Tracker.html"; // if internet connection found, redirect.
          } else {
          }
      }
  };
  rq.send(""); 
  var xmlHttpTimeout=setTimeout(ajaxTimeout,5000);
  function ajaxTimeout(){
     rq.abort();
  // IF no internet connection found, call this whole javascript function/code AGAIN in 5 seconds! to check for internet connection
  }
  </code></pre>
  
  <p>Basically, I want to check for internet connection without having to refresh my whole page - and if there is, then redirect to <code>Tracker.html</code></p>