× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

How to detect online/offline event cross-browser?

Leniel Macaferi
Feb 02, 2015
<p>Today there's an open source JavaScript library that does this job: it's called <a href="https://github.com/HubSpot/offline"><code>Offline.js</code></a>.</p> <blockquote> <p>Automatically display online/offline indication to your users.</p> </blockquote> <p><a href="https://github.com/HubSpot/offline">https://github.com/HubSpot/offline</a></p> <p>Be sure to check the full <a href="https://github.com/HubSpot/offline/blob/master/README.md">README</a>. It contains events that you can hook into.</p> <p>Here's a <a href="http://craigshoemaker.github.io/offlinejs-simulate-ui/">test page</a>. It's beautiful/has a nice feedback UI by the way! :)</p> <blockquote> <p>Offline.js Simulate UI is an Offline.js plug-in that allows you to test how your pages respond to different connectivity states without having to use brute-force methods to disable your actual connectivity.</p> </blockquote> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/3181080/How%20to%20detect%20online/offline%20event%20cross-browser?/23903156">Stack Overflow</a>.</p>
comments powered by Disqus