Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
2
12
1.5
4
18
3.2

The offline event of the Window interface is fired when the browser has lost access to the network and the value of Navigator.onLine switches to false.

3
12
9
4
18
3

The online event of the Window interface is fired when the browser has gained access to the network and the value of Navigator.onLine switches to true.

3
12
9
4
18
3

The offline event of the WorkerGlobalScope fires when the device loses connection to the internet.

29
8
8

The online event of the WorkerGlobalScope fires when the device reconnects to the internet.

29
8
8

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.

4
12
3.5
4
18
5
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 1 item(s)
Implementation note
  • 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, macOS: 14, ChromeOS: 13, Linux: Always returns `true`. For history, see bug 40530968.
Notes 1 item(s)
Implementation note
  • Since Firefox 4 the browser returns `true` when 'Work Offline' mode is disabled and `false` when it is enabled, regardless of actual connectivity. 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`).
Notes 1 item(s)
Implementation note
  • Since Firefox 4 the browser returns `true` when 'Work Offline' mode is disabled and `false` when it is enabled, regardless of actual connectivity. 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`).

Use cases

  • Using Online status

    The onLine property of the Navigator interface returns whether the device is connected to the network, with true meaning online and false meaning offline.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.