Table of contents
1.
Introduction
2.
Properties in JavaScript Navigator
2.1.
1. appName:
2.2.
2. appVersion:
2.3.
3. appCodeName:
2.4.
4. cookieEnabled:
2.5.
5. userAgent:
2.6.
6. language:
2.7.
7. userLanguage:
2.8.
8. systemLanguage:
2.9.
9. plugins:
2.10.
10. mimeTypes
2.11.
11. platform:
2.12.
12. online:
3.
Methods in JavaScript Navigator
4.
Frequently asked question
5.
Key Takeaways
Last Updated: Mar 27, 2024

JS Navigator

Introduction

JavaScript Navigator object stores information about the visiting browser. It contains information like app name, app version, language, platform, etc. 

 

The Navigator object provides attributes that transmit information about the browser. The userAgent property, for example, is a property of the window.navigator object. The web browser is identified by a long string.


Since Javascript Navigator is a window property, it can also be accessed with a window prefix.

For example, navigator can also be accessed as window.navigator


This article is all about the navigator object of JavaScript. So, let’s get started!

Also Read, Javascript hasOwnProperty

Properties in JavaScript Navigator

There are many properties associated with Navigator objects. Let's check them out!!

The following table denotes the various properties available in the Navigator:

No.  Property  Description
1 appName returns the name
2 appVersion returns the version
3 appCodeName returns the code name
4 cookieEnabled returns true if cookie is enabled otherwise false
5 userAgent returns the user agent
6 language returns the language. It is supported in Netscape and Firefox only.
7 userLanguage returns the user language. It is supported in IE only.
8 plugins returns the plugins. It is supported in Netscape and Firefox only.
9 systemLanguage returns the system language. It is supported in IE only.
10 mimeTypes[] returns the array of mime type. It is supported in Netscape and Firefox only.
11 platform returns the platform e.g. Win32.
12 online It returns true if the browser is online; otherwise false.

 

We shall see the properties in detail:

1. appName:

The appName property is used to fetch the name of the browser

Syntax:

navigator.appName

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML ="navigator.appName is " + navigator.appName;
</script>

2. appVersion:

The appVersion property returns the version of the browser.

Syntax:

navigator.appVersion

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML = navigator.appVersion;
</script>

3. appCodeName:

This property gives the application code name of the browser

Syntax:

navigator.appCodeName

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML =
"navigator.appCodeName is " + navigator.appCodeName;
</script>

4. cookieEnabled:

This property returns true if cookies are enabled. Otherwise, it returns false.

Syntax:

navigator.cookieEnabled

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML =
"cookiesEnabled is " + navigator.cookieEnabled;
</script>

5. userAgent:

This property returns the user-agent header sent by the browser to the server.

Syntax:

navigator.userAgent

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML = navigator.userAgent;
</script>

6. language:

The language property gives us the browser’s language.

Syntax:

navigator.language

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML = navigator.language;
</script>

7. userLanguage:

This property retrieves the operating system’s natural language setting.

Syntax:

navigator.userLanguage

Example:

<script type="text/javascript">
       function GetLangInfo () {
           var message = "";
           message += "<br />Regional and Language settings of the operating system: " +           window.navigator.userLanguage;
           }
          var output = document.getElementById ("output");
           output.innerHTML = message;
       }
   </script>

8. systemLanguage:

This property returns the language edition of the operating system.

          Syntax:

navigator.systemLanguage

 

          Example:

<script type="text/javascript">
       function GetLangInfo () {
           var message = "";
           message += "<br />Regional and Language settings of the operating system: " +           window.navigator.systemLanguage;
           }
          var output = document.getElementById ("output");
           output.innerHTML = message;
       }
   </script>

9. plugins:

This property returns a PluginArray object, listing the Plugin objects describing the plugins installed in the application.

Syntax:

navigator.plugins

Example:

var pluginsLength = navigator.plugins.length

10. mimeTypes

This property returns a MimeTypeArray object that contains a list of MimeType objects that represent the browser's MIME types.

Syntax:

navigator.mineTypes

Example:

function getJavaPluginDescription() {
 var mimetype = navigator.mimeTypes['application/x-java-applet'];
 if (mimetype === undefined) {
   // no Java plugin present
   return undefined;
 }
 return mimetype.enabledPlugin.description;
}

11. platform:

The platform property returns the browser operating system.

Syntax:

navigator.platform

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML = navigator.platform;
</script>

12. online:

The onLine property returns true if the browser is online.

Syntax:

navigator.onLine

Example:

<p id="test"></p>

<script>
document.getElementById("test").innerHTML = navigator.onLine;
</script>

Methods in JavaScript Navigator

There are two methods available in the JavaScript navigator object. 

  1. javaEnabled(): Specifies whether or not the browser has Java enabled.

Example: 

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = navigator.javaEnabled();
</script>

 

2. taintEnabled(): This function is used to check if taint is enabled. It is deprecated since JavaScript 1.2

Example:

var nav= navigator.taintEnabled()

This was all about the JavaScript Navigator Object. Let’s move on to faqs.

Frequently asked question

1). What is JavaScript Navigator?

Ans: JavaScript Navigator is an object in JS which returns information about the browser.


2). What kind of information can the navigator provide?

Ans: The navigator object can provide information like the name of the application, code name, version, if cookie is enabled, online status, etc.

 

3). What are the different methods in the navigator?

Ans: The navigator object has 2 methods:

  1. javaEnabled()
  2. taintEnabled()

Key Takeaways

JavaScript Navigator is a javascript object which provides us with information regarding the browser. It helps us find the name, code name, version, online status, cookie enable status, etc. 


This is done using different properties provided by navigator. JavaScript Navigator also has some methods to find the java enabled status of the browser.


We also have other interesting articles related to JavaScript like JavaScript Fetch APIFunction node.jsjQuery introduction and many more. Click the links to read more about the topics.


Happy learning!

Live masterclass