Navigator onLine Property

Navigator 对象参考手册Navigator Object

Definition and Usage

The Navigator onLine property determines whether the browser is online, returning true if online, otherwise false.

Navigator onLine is a read-only property.



Syntax

navigator.onLine 


Return Value

Type Description
BooleanReturns true if online, otherwise false.


Browser Support

All major browsers support the onLine property

Chrome IE Edge Firefox Safari Opera
Yes Yes Yes Yes Yes Yes

Example

Display all browser properties:

Example

let online = navigator.onLine;

Try it yourself »
Navigator 对象参考手册Navigator Object Other Extensions