JavaScript Window Navigator

The window.navigator object contains information about the visitor.

Window Navigator

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

Some examples:

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

Browser Cookie

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

Example

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

Try It Yourself

Browser Application Name

appName The property returns the application name of the browser:

Example

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

Try It Yourself

Sound strange, "Netscape" is a general term for the application name of IE11, Chrome, Firefox, and Safari.

Browser Application Code Name

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

Example

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

Try It Yourself

"Mozilla" is the application code name for Chrome, Firefox, IE, Safari, and Opera.

Browser Engine

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

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = "navigator.product is " + navigator.product;
</script>

Try It Yourself

Browser Version

appVersion The property returns information about the browser version:

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.appVersion;
</script>

Try It Yourself

Browser Agent

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

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.userAgent;
</script>

Try It Yourself

Warning!!!

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

  • Different browsers can use the same name
  • Navigation data can be changed by the browser owner
  • Some browsers may incorrectly identify themselves to bypass site testing
  • The browser cannot report a new operating system released later than the browser

Browser Platform

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

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.platform;
</script>

Try It Yourself

Browser Language

language The property returns the browser language:

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.language;
</script>

Try It Yourself

Is the browser online?

onLine The property returns true if the browser is online:

Example

<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = navigator.onLine;
</script>

Try It Yourself

Is Java enabled?

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

Example

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

Try It Yourself