how to check if user lost internet connection

Sometimes losing time on the web I noticed some websites have specific ways to deal with a user who has lost his connections. I wonder how. Is there an event that fires when this happens?
10 Replies
Jochem
Jochem•4mo ago
MDN Web Docs
Window - Web APIs | MDN
The Window interface represents a window containing a DOM document; the document property points to the DOM document loaded in that window.
Pi (I'll eat who dont correct me
When a user loses his internet connection, how much time it takes for this to happen?
No description
Jochem
Jochem•4mo ago
Should be as soon as the OS notices
MarkBoots
MarkBoots•4mo ago
could take a few seconds. i remember vaguely the browsers are checking the status every x-time
Pi (I'll eat who dont correct me
It is a tricky one because it can returns false positivies
No description
MarkBoots
MarkBoots•4mo ago
that is navigator.online property, different rom the online/offline events
Pi (I'll eat who dont correct me
The online /offline events is based on that property
MarkBoots
MarkBoots•4mo ago
🤭 I can't read
Pi (I'll eat who dont correct me
As here says
MarkBoots
MarkBoots•4mo ago
yup