Navigator onLine Property
Navigator Object
Example
Find out whether the browser is online:
var x = "Is the browser online? " + navigator.onLine;
The result of x will be:
Try it yourself »
More "Try it Yourself" examples below.
Definition and Usage
The onLine property returns a Boolean value that specifies whether the
browser is in online or offline mode.
Note: This property is read-only.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property |
|
|
|
|
|
onLine |
14.0 |
Yes |
3.5 |
5.0.4 |
Yes |
Syntax
Technical Details
Return Value: |
A Boolean, indicating whether the browser is in online or offline mode.
Returns true if the browser is online, otherwise it returns false |
More Examples
Example
A demonstration of all navigator properties in one example:
var txt = "";
txt += "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt +=
"<p>Browser Name: " + navigator.appName + "</p>";
txt += "<p>Browser
Version: " + navigator.appVersion + "</p>";
txt += "<p>Cookies Enabled: "
+ navigator.cookieEnabled + "</p>";
txt += "<p>Browser
Language: " + navigator.language + "</p>";
txt +=
"<p>Browser Online: " + navigator.onLine + "</p>";
txt += "<p>Platform: " +
navigator.platform + "</p>";
txt += "<p>User-agent header: " +
navigator.userAgent + "</p>";
Try it yourself »
Navigator Object
Color Picker