title: How to check mobile internet connection
body: <p>I have to call two functions <strong>based</strong> on internet/connection availability. </p>
  
  <p>If there is internet connection <strong>present</strong> then call insert function, otherwise call update.</p>
  
  <p>I tried like this: </p>
  
  <pre><code>var online = window.navigator.onLine;
      if (online==ture) {
          alert('connection down.');
      }else
      {
        alert('Please check your internet connection and try again');
      }
  </code></pre>
  
  <p>This code works in browser only but not on device.It always shows <code>alert('connection down');</code> in both cases i.e. internet is present or not.</p>
  
  <p>Please guide on this code as I am new to Phonegap. </p>