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?
The navigator. onLine attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail), and must return true otherwise. So the spec defines the behaviour that should result in a false value.
Unfortunately, though, navigator. onLine is considered an unreliable API. In Chrome and Safari it only determines whether a device has connection to a network, not whether or not that network can actually reach the internet. However, for some purposes, navigator.
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.
You can use the navigator . onLine property in JavaScript to find out whether your browser in online or offline. It actually gives you status of your internet connection.
Do you have something like Virtual Box or VMWare installed? Even VPN applications act as virtual network adapters and will make navigator.onLine === true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With