W3cubDocs

/DOM

navigatorOnLine

The NavigatorOnLine interface contains methods and properties related to the connectivity status of the browser.

There is no object of type NavigatorOnLine, but other interfaces, like Navigator or WorkerNavigator, implement it.

Properties

The NavigatorOnLine interface doesn't inherit any property.

NavigatorOnLine.onLine Read only
Returns a Boolean indicating whether the browser is working online.

Methods

The NavigatorOnLine interface neither implements, nor inherit any method.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'NavigatorOnLine' in that specification.
Living Standard No change from the latest snapshot, HTML5
HTML5
The definition of 'NavigatorOnLine' in that specification.
Recommendation Snapshot of HTML Living Standard with its initial specification.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes ? Yes Yes Yes Yes
Support on WorkerNavigator ? ? 29 ? ? ?
onLine Yes
Yes
Earlier versions of Chrome incorrectly return true when a tab is first opened, but it starts reporting the correct connectivity status after the first network event. Windows: 11, Mac: 14, Chrome OS: 13, Linux: Always returns true. For history, see crbug.com/7469.
Yes 3.5
3.5
Since Firefox 4 the browser returns true when 'Work Offline' mode is disabled and false when it is enabled, regardless of actual connectivity.
4
Since Firefox 41, on OS X and Windows, the returned values follow the actual network connectivity, unless 'Work offline' mode is selected (where it will always return false).
8
8
in Internet Explorer 8 'online' and 'offline' events are raised on the document.body; under IE 9 they are raised on both document.body and window.
No
No
Since Opera 11.10, the browser returns true when 'Work Offline' mode is disabled and false when it is enabled, regardless of actual connectivity.
5
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? Yes Yes Yes ?
Support on WorkerNavigator ? 29 ? 35 ? ? ?
onLine Yes
Yes
Faulty in a WebView component, see Issue bug 16760.
Yes Yes 4 ? Yes ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/navigatorOnLine