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

JavaScript Basic Tutorial

JavaScript Object

JavaScript Function

JS HTML DOM

JS Browser BOM

AJAX Basic Tutorial

JavaScript Reference Manual

JS Window Navigator

The window's navigator property (i.e., window.navigator) is a reference to the Navigator object.

Navigator object

window.navigatorThe object contains information about the user's browser.

window.navigatorYou can write objects without a window prefix.

Some examples:

The next section will show you how to obtain various information about the user's browser.

Browser application name

navigator.appNameThe property returns the name of the browser.

var x = navigator.appName;
Test See‹/›

Note:Note: Do not rely on this property to return the correct browser name. All browsers return 'Netscape' as the value of this property.

Browser application code name

navigator.appCodeNameThe property returns the code name of the browser.

var x = navigator.appCodeName;
Test See‹/›

Note:Do not rely on this property to return the actual product name. All browsers return"Mozilla"As the value of this property.

Browser engine

navigator.productThe property returns the name of the browser's product (engine).

var x = navigator.product;
Test See‹/›

Note:Do not rely on this property to return the actual engine name. All browsers return"Gecko"As the value of this property.

Browser version

navigator.appVersionThe property returns the version information of the browser.

var x = navigator.appVersion;
Test See‹/›

Browser userAgent

navigator.userAgentThe property returns the value of the user agent header sent by the browser to the server.

var x = navigator.userAgent;
Test See‹/›

Instructions for use

Information from the Navigator object usually leads to misinterpretation and should not be used to detect browser versions, because:

  • Different browsers can use the same name

  • Navigator data can be changed by the browser owner

  • Some browsers incorrectly identify themselves to bypass site tests.

  • Browsers cannot report new operating systems released after the browser release.

Browser platform

navigator.platformThe property returns a string representing the browser platform (operating system).

var x = navigator.platform;
Test See‹/›

Browser language

Thenavigator.languageThe property returns the language version of the browser.

var x = navigator.language;
Test See‹/›

browser cookies

Thenavigator.cookieEnabledThe property returns a boolean value that specifies whether cookies are enabled in the browser.

This property returns if cookies are enabled.trueotherwise it returnsfalse.

var x = navigator.cookieEnabled;
Test See‹/›

You can find in ourIn the JavaScript Cookies tutorialLearn more about cookies.

Is the browser online?

navigator.onLineThe property returns a boolean value that specifies whether the browser is in online or offline mode.

This property returns if the browser is online.trueotherwise it returnsfalse.

var x = navigator.onLine;
Test See‹/›

Is Java enabled?

navigator.javaEnabled()The method returns a boolean value that specifies whether Java is enabled in the browser.

This method returns a boolean value if Java is enabled in the browser.trueotherwise it returnsfalse.

var x = navigator.javaEnabled();
Test See‹/›

Java is a面向对象的编程语言 owned by Oracle.

More Examples

This example displays all Navigator properties:

var txt = "";
txt += "<p>Browser Code Name: " + 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>Browser Platform: " + navigator.platform + "</p>";
txt += "<p>User-agent header: " + navigator.userAgent + "</p>";
document.write(txt);
Test See‹/›

Complete Navigator Reference

For a complete reference to properties and methods, please visit ourJavaScript Navigator Object Reference Manual.

The reference part includes descriptions and examples of all Navigator properties and methods.