Open Playground
JS Browser BOMLesson #177

JavaScript Window Navigator

The navigator object contains information about the visitor's browser.

The Navigator Object

The navigator object contains information about the visitor's browser.

It can be written with or without the window prefix like:

windows.navigator or just navigator

Browser Cookies

The cookieEnabled property returns true if cookies are enabled, otherwise false:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML =
"cookiesEnabled is " + navigator.cookieEnabled;

The Browser Language

The language property returns the browser's language:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.language;

Is The Browser Online?

The onLine property returns true if the browser is online:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.onLine;

Browser Application Name

The appName property returns the application name of the browser:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML =
"navigator.appName is " + navigator.appName;
Warning > This property is removed (deprecated) in the latest web standard. > Most browsers (Chrome, Edge, Firefox, Safari) returns Netscape as > appName.

Browser Application Code Name

The appCodeName property returns the application code name of the browser:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML =

 "navigator.appCodeName is " + navigator.appCodeName;
Warning > This property is removed (deprecated) in the latest web standard. > Most browsers (Chrome, Edge, Firefox, Safari) returns Mozilla as > appCodeName.

The Browser Engine

The product property returns the product name of the browser engine:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML =

 "navigator.product is " + navigator.product;
Warning > This property is removed (deprecated) in the latest web standard. > Most browsers returns Gecko as product.

The Browser Version

The appVersion property returns version information about the browser:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.appVersion;
Warning > This property is removed (deprecated) in the latest web standard. > Do not rely on appVersion to return the correct browser version.

The Browser Agent

The userAgent property returns the user-agent header sent by the browser to the server:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.userAgent;

Warning

The information from the navigator object can often be misleading.

The navigator object should not be used to detect browser versions because:

  • Different browsers can use the same name
  • The navigator data can be changed by the browser owner
  • Some browsers misidentify themselves to bypass site tests
  • Browsers cannot report new operating systems, released later than the browser

The Browser Platform

The platform property returns the browser platform (operating system):

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.platform;
Warning > This property is removed (deprecated) in the latest web standard. > Do not rely on platform to return the correct browser platform in all browsers.

Is Java Enabled?

The javaEnabled() method returns true if Java is enabled:

Example

Example Code

html
Try it Yourself
document.getElementById("demo").innerHTML = navigator.javaEnabled();
Warning > This method is removed (deprecated) in the latest web standard. > javaEnabled() always returns false.

Interactive Code Examples

JS Example 1

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview:

JS Example 2

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview:

JS Example 3

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview:

JS Example 4

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview:

JS Example 5

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview:

JS Example 6

html
Try it Yourself
Interactive runnable JavaScript example from EA Academy.
Live Output Preview: