Online-js
Checking internet connection.
Browser Support
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |
Installing
npm i online-js --save# oryarn add online-js
Usage
Basic
const statusChecker =const callback = {if status === trueconsoleelseconsole}statusChecker
Advanced
// Options with default valuesconst options =url: 'favicon.ico' // Link on your site. Cross-domain requests not supporteddelay: 2 // Delay between checking in secondsstartOnload: true // Start checking after page loadconst statusChecker =// Add listenersstatusChecker// Removing listenersstatusChecker // SinglestatusChecker // All// MethodsstatusChecker // Single checkingstatusCheckerstart // Start checking. Don't forget to add a listenerstatusChecker // Stop checking
Using with Vue.js
Vueprototype$online ={this$online}
License
MIT