WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript Window Navigator


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


Window Navigator

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

Some examples:

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

Navigator Cookie Enabled

The property cookieEnabled returns genuine if treats are empowered, something else false:

Example

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

<script>
document.getElementById("demo").innerHTML =
"Cookies Enabled is " + navigator.cookieEnabled;
</script>
Try it Yourself »

The Browser Names

The properties appName and appCodeName return the name of the browser:

Example

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

<script>
document.getElementById("demo").innerHTML =
"Name is " + navigator.appName + ". Code name is " + navigator.appCodeName;
</script>
Try it Yourself »


The Browser Engine

The property product returns the motor name of the browser:

Example

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

<script>
document.getElementById("demo").innerHTML = navigator.product;
</script>
Try it Yourself »

The Browser Version I

The property appVersion returns adaptation data about the browser:

Example

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

<script>
document.getElementById("demo").innerHTML = navigator.appVersion;
</script>
Try it Yourself »

The Browser Version II

The property userAgent additionally returns adaptation data about the browser:

Example

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

<script>
document.getElementById("demo").innerHTML = navigator.userAgent;
</script>
Try it Yourself »


The Browser Platform

The property platform returns the program stage (working system):

Example

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

<script>
document.getElementById("demo").innerHTML = navigator.platform;
</script>
Try it Yourself »

The Browser Language

The property language returns the program's language:

Example

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

<script>
document.getElementById("demo").innerHTML = navigator.language;
</script>
Try it Yourself »

Is Java Enabled?

The strategy javaEnabled() returns genuine if Java is enabled:

Example

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

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

Warning !!!

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

  • navigator data can be changed by browser users
  • Some browsers recognize errors on test sites
  • Browser cannot report new operating systems released after the browser

Browser detection

Because navigator can mislead browser detection, using object detection can be used to sniff different browsers.

Because different browsers support different objects, you can use objects to detect the browser. For example, since only the Opera property "window.opera" is supported, you can identify Opera accordingly.

Example: if (window.opera) {... some action ...}