This is related to my previous question, but will navigator.onLine work if there is a bad connection? For example, the device is connected to a router, but no pages will load, or anything else that will bring an error that tells the user to check their connection. I know navigator.onLine works when completely disabling a connection, but there just isn’t a way to simulate a bad connection unless you experience a bad connection. If it doesn’t work, are there any tests I could do with javascript to ping a server?
This is related to my previous question, but will navigator.onLine work if there is
Share
From the documentation:
In other words, a bad connection will return
true.To answer your second question, yes, you can ping a server with an AJAX call to your server. If it is successful (you get a response back) then you know the browser is online. If it times out, the user could be experiencing a bad connection.