English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
navigator.onLine
var x = navigator.onLine; document.querySelector("#output").innerHTML = x;Test and See‹/›
The numbers in the table specify the first browser version that fully supports the onLine property:
Property | |||||
onLine | 14 | 3.5 | Yes | 5.1 | Yes |
Return value: | Boolean value, returns true if the browser is online, otherwise returns false |
---|
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‹/›
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