Window navigator.onLine property

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;

Try it yourself

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>";

Try it yourself

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