title: How to detect online/offline event cross-browser?
body: <p>I'm trying to accurately detect when the browser goes offline, using the HTML5 online and offline events.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&lt;script&gt;
      // FIREFOX
      $(window).bind("online", applicationBackOnline); 
      $(window).bind("offline", applicationOffline);
  
      //IE
      window.onload = function() {
          document.body.ononline = IeConnectionEvent;
          document.body.onoffline = IeConnectionEvent;
      } 
  &lt;/script&gt;
  </code></pre>
  
  <p>It works fine when I just hit "Work offline" on either Firefox or IE, but it's kind of randomly working when I actually unplug the wire. </p>
  
  <p>What's the best way to detect this change? I'd like to avoid repeating ajax calls with timeouts.</p>