Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google chrome navigator onLine always true

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?

like image 776
Dickens A S Avatar asked Mar 29 '16 06:03

Dickens A S


People also ask

Why is Navigator onLine false?

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.

Is Navigator onLine reliable?

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.

How navigator onLine works?

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.

How can I tell if my browser is offline or onLine?

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.


1 Answers

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

like image 135
Vincent J. Michuki Avatar answered Sep 23 '22 15:09

Vincent J. Michuki