Online and offline state
Tells the page whether the device believes it has a network.
In one line
Can tell if your device thinks it is online, and when that changes
Tells the page whether the device believes it has a network.
Boolean only; true can still mean a captive portal or no internet. Events fire when the device loses or regains connection, revealing travel, elevators, flights.
What it can and can't do
What the user does: Nothing. It happens while the page is open and your connection changes
It can
- See a yes or no answer for being online
- Notice when you lose or regain a connection
- Switch to an offline mode and save your work for later
It cannot
- Know if the internet truly works, since a hotel login page still counts as online
- See which network you are on
- See your location, though repeated drops can hint you are on the move
- Work after you close the tab
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 2 | 2009-05-21 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 1.5 | 2005-11-29 | None |
| Safari | Supported | 4 | 2009-06-08 | None |
| Safari on iPhone | Supported | 3.2 | 2010-04-03 | None |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | navigator.onLine, 'online' and 'offline' events |
| Browser compat keys | api.Navigator.onLine |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | read fresh on every page load; nothing stored |
| How to take it back | none needed (no grant) |
| Inside an iframe | Readable from cross-origin iframes too (same values) |
Typical flow
- Page script reads the value
- No prompt is shown
Data you get
Shape: object
How often: static per session
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
onLine | boolean | None | true or false | Not listed |
Technical limits
- True means a link, not working internet
The story
What it is
A page knows whether your device thinks it is online, and gets told when that changes.
For you
You may see a banner like You are offline, or a message that your changes will sync later. When the signal returns, the page catches up for you.
For makers
Makers use it to protect user work, to switch to a saved copy and to retry actions. It is a simple signal, but it can be wrong, as a device can look online with no real internet.
Where you see it
| Type | Example | Apps |
|---|---|---|
| productivity | Google Docs shows Offline in the top bar when your signal drops, keeps your typing and syncs when you reconnect. | Google Docs |
| games | A browser game pauses and shows Reconnecting when the signal drops, then rejoins the match when it returns. | None named |
| video | A web streaming app switches to downloaded titles when it sees the device is offline. | Netflix |
| social | A chat site shows a clock icon on unsent messages while offline and sends them when back online. | None named |
| shopping | A shop keeps a cart on the device when offline and syncs it when online. | None named |
| creative | A web design tool like Figma warns that edits are saved on this device only until a connection returns. | Figma |
| news | A news site shows saved articles while you ride through a tunnel. | None named |
Risks
- Can be wrong
- Little privacy risk
What the platform says
- MDN Web Docs: Navigator onLine. Pages can react when the device goes offline or comes back, for example to save work for later.
Good uses and abuse
Legitimate uses
- Offline mode
Known abuse
- Presence timing
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 0.1 | Rough identifying entropy, when known |
Sources
How well checked: Based on official documentation.