Javascript
Check internet status with Javascript
On November 20, 2022 by Sonahang RaiJavascript is so powerfull. Nowadays we can see that there are lots of web app being used offline with the PWA implementation. Thats because javascript has the ability to detect if the client is connected to the internet or not.
We can simple listen to the javascript window to know about the clients connectivity status. And we can simply perform anything we want after the listened value is satisfied.
window.addEventListener("online", function () {
//Online Listener
//Perform anything you want in your website
//When this online event is satisfied
});
window.addEventListener("offline", function () {
//Offline Listener
//Perform anything you want in your website
//When this offline event is satisfied
});
You can check my implemtation video in youtube.
Archives
Calendar
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |