JS Navigator

JS Tutorial

JS Version

JS Objects

JS Function

JS Classes

JS Async

JS HTML DOM

JS Browser BOM

JS Web API

JS AJAX

JS JSON

JS vs JQUERY

JS Graphics

JS Navigator

The window.navigator object consists of information related to the visitor’s browser.

Window Navigator

The window.navigator object can be written without the window prefix.

  • Some examples:
  • appName
  • appCodeName
  • platform

Browser Cookies

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

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The cookieEnabled property returns true if cookies are enabled:</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.cookieEnabled is ” + navigator.cookieEnabled;

</script>

</body>

</html>

Output

The Navigator Object

The cookieEnabled property returns true if cookies are enabled:

Browser Application Name

The appName property is used return the application name of the browser.

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The appName property returns the application name of the browser:</p>

<p id=”demo”></p>

<p>Strange enough, “Netscape” is the application name for IE11, Chrome, Firefox, and Safari.</p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.appName is ” + navigator.appName;

</script>

</body>

</html>

Output

The Navigator Object

The appName property returns the application name of the browser:

navigator.appName is Netscape

Strange enough, "Netscape" is the application name for IE11, Chrome, Firefox, and Safari.

Browser Application Code Name

The appCodeName property is used to return the application code name of the browser.

Example

<!DOCTYPE html>

<html>

<body>

<h2>JavaScript Navigator</h2>

<p>The appCodeName property returns the code name of the browser.</p>

<p>Do not rely on it! “Mozilla” is the application code name for Chrome, Firefox, IE, Safari, and Opera.</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.appCodeName is ” + navigator.appCodeName;

</script>

</body>

</html>

Output

JavaScript Navigator

The appCodeName property returns the code name of the browser.

Do not rely on it! "Mozilla" is the application code name for Chrome, Firefox, IE, Safari, and Opera.

navigator.appCodeName is Mozilla

The Browser Engine

The product property is used to return the product name of the browser engine:

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The product property returns the product name of the browser.</p>

<p>Do not rely on it! Most browsers return “Gecko” as the roduct name!</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.product is ” + navigator.product;

</script>

</body>

</html>

Output

The Navigator Object

The product property returns the product name of the browser.

Do not rely on it! Most browsers return "Gecko" as the roduct name!

navigator.product is Gecko

The Browser Version

The appVersion property is used to return version information about the browser:

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The appVersion property returns version information about the browser:</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML = navigator.appVersion;

</script>

</body>

</html>

Output

The Navigator Object

The appVersion property returns version information about the browser:

5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.25

The Browser Agent

The userAgent property is used to return the user-agent header sent by the browser to the server.

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The userAgent property returns the user-agent header sent by the browser to the server:</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

navigator.userAgent;

</script>

</body>

</html>

Output

The Navigator Object

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

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.25

The Browser Platform

The platform property is used to return the browser platform (operating system).

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The platform property returns the browser platform (operating system):</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.platform is ” + navigator.platform;

</script>

</body>

</html>

Output

The Navigator Object

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

navigator.platform is Win32

The Browser Language

The language property is used to return the browser’s language.

Example

<!DOCTYPE html>

<html>

<body>

<h2>The Navigator Object</h2>

<p>The language property returns the browser’s language:</p>

<p id=”demo”></p>

<script>

document.getElementById(“demo”).innerHTML =

“navigator.language is ” + navigator.language;

</script>

</body>

</html>

Output

The Navigator Object

The language property returns the browser's language:

navigator.language is en-US


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/u212091429/domains/mydevhelp.com/public_html/wp-includes/functions.php on line 5420