To check internet connection is active or not in the web page we can use the Offline.js plugin
Clone the git repository and include the offline.min.js file and any theme css file like offline-theme-slide.css with language css file offline-language-english.css
By default it will ping favicon.ico file in the server, we can customize it to any request
Offline.options = {checks: {image: {url: 'path/to/favicon/image'}, active: 'image'}}
To check the current status of the connection
Offline.check()
To check the current state of the connection 'up' or 'down'
Offline.state
To set event listener once connection is up
Offline.on('up', function(){ console.log('Connection is up.'); });
To set event listener once connection is down
Offline.on('down', function(){ console.log('Connection is down.'); });
No comments:
Post a Comment