https://github.com/pixelscommander/onlinejs
Reliable, fast and easy to use library to check your internet connection status
https://github.com/pixelscommander/onlinejs
Last synced: 8 months ago
JSON representation
Reliable, fast and easy to use library to check your internet connection status
- Host: GitHub
- URL: https://github.com/pixelscommander/onlinejs
- Owner: PixelsCommander
- Created: 2012-05-24T00:59:27.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2018-01-20T19:59:19.000Z (over 8 years ago)
- Last Synced: 2025-05-15T20:04:50.105Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://pixelscommander.com/polygon/onlinejs/
- Size: 111 KB
- Stars: 69
- Watchers: 13
- Forks: 17
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ONLINE JS
========
Lightweight and reliable library to check internet connection status.
Compatible browsers: IE 8-11, Opera, Chrome, Firefox, Android, iOS
Usage
-----
Include this library into your project and just check is window.onLine === true.
Assign window.onLineHandler or window.offLineHandler functions to handle status changes.
Just look at example (index.html in the repo)!
More info in this blog post.
Safety and guarantees
---------------------
Library requests headers from public URL to check if internet is available. URL set by default is maintained by me and there is no guarantee I am going to run it forever. In order to make it safe for your application it is recommended to run your own URL responding with header Access-Control-Allow-Origin: * and then switch Online.JS to it by setting window.onLineURL.
navigator.onLine
----------------
I`m often asked: “Why not just use navigator.onLine ?”.
Using this property in critical tasks is bad idea. Property is underhandled and is not consistent among all browsers. It can show local connection status or react only on autonomous mode switching. Online JS is better way for serious project, it uses navigator.onLine and corresponding events as one of possible triggers and then makes more checks of internet connection.
Questions and propositions
--------------------------
Feel free to write me with any questions or propositions denis.radin@gmail.com
Bug tracker
-----------
Have a bug? Please create an issue here on GitHub!
https://github.com/PixelsCommander/OnlineJS/issues
Twitter account
---------------
Keep up to date on announcements and more by following OnlineJS on Twitter, @pixelscommander.
License
---------------------
Copyright 2011 Denis Radin.
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0