English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The window's navigator property (i.e., window.navigator) is a reference to the 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.
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.
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.
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.
navigator.appVersionThe property returns the version information of the browser.
var x = navigator.appVersion;Test See‹/›
navigator.userAgentThe property returns the value of the user agent header sent by the browser to the server.
var x = navigator.userAgent;Test See‹/›
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.
navigator.platformThe property returns a string representing the browser platform (operating system).
var x = navigator.platform;Test See‹/›
Thenavigator.languageThe property returns the language version of the browser.
var x = navigator.language;Test See‹/›
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.
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‹/›
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.
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‹/›
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.