English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Navigator onLine Property

JavaScript Navigator Object

onLineA read-only property returns a boolean value indicating whether the browser is in online or offline mode.

If the browser is online, this property returnstrue, otherwise returnsfalse.

Syntax:

navigator.onLine
var x = navigator.onLine;
document.querySelector("#output").innerHTML = x;
Test and See‹/›

Browser compatibility

The numbers in the table specify the first browser version that fully supports the onLine property:

Property
onLine143.5Yes5.1Yes

Technical details

Return value:Boolean value, returns true if the browser is online, otherwise returns false

More examples

This example displays all Navigator properties:

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>";
document.write(txt);
Test and See‹/›

Related References

Navigator Reference:navigator.appCodeName property

Navigator Reference:navigator.appname property

Navigator Reference:navigator.cookieEnabled property

Navigator Reference:navigator.language property

Navigator Reference:navigator.platform property

Navigator Reference:navigator.userAgent property

JavaScript Navigator Object