title: Check if there is an internet connection
body: <p>How to check if there is an internet connection in Javascript?
  I have searched in Google but I have not found a good solution for my problem.</p>
  <p>I have already got two eventhandler:</p>
  <pre><code>document.body.addEventListener(&quot;offline&quot;, function () {
      //alert(&quot;offline&quot;)
      masterViewModel.online(false)
  }, false);
  document.body.addEventListener(&quot;online&quot;, function () {
      //alert(&quot;online&quot;)
      masterViewModel.online(true);
  }, false);
  </code></pre>
  <p>But how to check in the &quot;onload&quot;-function if I am online?</p>