BOM Navigator (Window Navigator)

The window.navigator object contains information about the user’s browser.


Window Navigator

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

Some below examples to get the browser details:

  • navigator.appName
  • navigator.appCodeName
  • navigator.platform

Browser Cookies

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

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

<p id="result"></p>

<script>
document.getElementById("result").innerHTML =
"Your browser cookieEnabled is " + navigator.cookieEnabled;
</script>

</body>
</html>

Output :-


Browser Application Name

The appName property used to return the application name of the browser:

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

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

<p>Strange enough, "Netscape" is the application name for IE11, Chrome, Firefox, and Safari.</p>
<p id="result"></p>

<script>
document.getElementById("result").innerHTML =
"Your browser name is " + navigator.appName;
</script>

</body>
</html>

Output :-

Note:- Strange enough, “Netscape” is the application name for both IE11, Chrome, Firefox, and Safari.


Browser Application Code Name

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

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

<p id="result"></p>

<script>
document.getElementById("result").innerHTML =
"Your browser name is " + navigator.appCodeName;
</script>

</body>
</html>

Output :-

Note:- “Mozilla” is the application code name for both Chrome, Firefox, IE, Safari, and Opera.


Browser Engine

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

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

<p>Do not trust on it! Most browsers returns "Gecko" as product name!</p>
<p id="result"></p>

<script>
document.getElementById("result").innerHTML =
"Your browser name is " + navigator.product;
</script>

</body>
</html>

Output :-

Note:- Do not rely on this. Most browsers returns “Gecko” as product name !!


Browser Version

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

<p>The appVersion property returns version information about the browser:</p>
<p id="result"></p>

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

</body>
</html>

Output :-


Browser Agent

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

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

<p id="result"></p>

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

</body>
</html>

Output :-

Warning !!!

The information from the navigator object can often be misleading, and should not be used to detect browser versions because:

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

The Browser Platform

The platform property used to return the browser platform (OS – operating system):

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

<p>The platform property returns the browser platform (OS):</p>
<p id="result"></p>

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

</body>
</html>

Output :-


Browser Language

The language property used to return the browser’s language:

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

<p>The language property returns the browser language:</p>
<p id="result"></p>

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

</body>
</html> 

Output :-


Is Browser Online?

The onLine property used to return the browser status. If it is online then will return true:

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

<p>The onLine property returns the browser online status:</p>
<p id="result"></p>

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

</body>
</html> 

Output :-


Is Java Enabled?

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

Input:-
<!DOCTYPE html>
<html>
<body>

<h2>JS Navigator</h2>

<p>The javaEnabled property returns the status of java if enabled or not:</p>
<p id="result"></p>

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

</body>
</html> 

Output :-