I'm trying to alert users when they are offline, and show a simple message. I'm using Offline.js as a library (Offline.js website).
I want to write JS and not use Eager to install it automatically.
Here is what I wrote, but it doesn't seem to be working. Can someone help me with more details?
I couldn't find a sample with code on the library website.
Offline.options = {checkOnLoad: true, checks: {image: {url: 'http://www.vitaminedz.com/photos/49/02-49565-front-de-mer-a-oran.jpg'}, active: 'image'}}
Offline.check();
Offline.on('up', alert('up'));
Offline.on('down',alert('down'));
JSFiddle Code + DEMO
Your handlers are not set properly. It should be like this:
alert(Offline.check());
Offline.on('up', function() {
alert('up');
});
Offline.on('down', function() {
alert('down')
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With