Window navigator.onLine property
- Previous Page language
- Next Page platform
- Go to Parent Level Window Navigator
Definition and usage
If the browser is online,onLine
The property returns true
, otherwise returns false
.
onLine
The property is read-only.
Tip:
This property is unreliable.
The computer can connect to the network without accessing the Internet.
Instance
Example 1
Is the browser online?
let online = navigator.onLine;
Example 2
Display all navigator properties:
Display all navigator properties:
let text = "<p>Browser CodeName: " + navigator.appCodeName + "</p>" + "<p>Browser Name: " + navigator.appName + "</p>" + "<p>Browser Version: " + navigator.appVersion + "</p>" + "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>" + "<p>Browser Language: " + navigator.language + "</p>" + "<p>Browser Online: " + navigator.onLine + "</p>" + "<p>Platform: " + navigator.platform + "</p>" + "<p>User-agent header: " + navigator.userAgent + "</p>";
Syntax
navigator.onLine
Return value
Type | Description |
---|---|
Boolean value | If the browser is online, it returns true, otherwise false. |
Browser Support
All Browsers Support navigator.onLine
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page language
- Next Page platform
- Go to Parent Level Window Navigator