7

Based on the mozilla developer network

https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/onLine

it says

Returns the online status of the browser. The property returns a boolean value, with true meaning online and false meaning offline. The property sends updates whenever the browser's ability to connect to the network changes. The update occurs when the user follows links or when a script requests a remote page. For example, the property should return false when users click links soon after they lose internet connection.

But when I pull the network cable and click a button and put

console.log(window.navigator.onLine)

It still return true

Does this means the technology is still not fully implemented by google chrome?

1
  • I used navigator.online the past month with chrome version 62 and it WAS working. What I did is I have a setInterval and console.log navigator.onLine and it prints false when when i turned off the wifi and then true then connected. But today it returns true everytime even if the wifi is disconnected. I dont have any lan cables connected too. I tried it in edge and its working fine. And also my friend also have chome 62 and doesnt have any problem using navigator.onLine Nov 16, 2017 at 10:47

2 Answers 2

2

In 2022 on Windows 10 and Chrome 99 it is still not reailable to to use that in order to determine connection status,

1
  • And some user reported me that they got navigator.onLine === false even both they and their webpage may connect to the internet without any troubles, in 2022.... (which broke our web applications)
    – tsh
    Nov 21, 2022 at 7:08
1

Do you have something like Virtual Box or VMWare installed? Even VPN applications act as virtual network adapters and will make navigator.onLine === true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.