5
Is there any way to "know", via javascript
, if the internet connection has been lost?
For example, to try a reconnection with websocket, if it detects that the internet connection has been lost and then has been reestablished.
5
Is there any way to "know", via javascript
, if the internet connection has been lost?
For example, to try a reconnection with websocket, if it detects that the internet connection has been lost and then has been reestablished.
6
navigator.onLine
works for real; however "online" does not refer to an internet connection, but any connection. If the user is connected to a VPN, but this VPN has no internet - navigator.onLine
will return true
also;
The best solution will be to make a request for GET
by ajax to any site and if that link does not fail you know that the user (most likely) is online.
@danguilherme! :)
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
navigator.onLine
really works?– Wallace Maxters
Create a route from your site to use as
ping
.– Oeslei