Skip to main content

JavaScript - Window Navigator

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 true if cookies are enabled, otherwise false:


Example


<id="demo"></p>

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

The Browser Names

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


Example


<id="demo"></p>

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

Did you know?

IE11, Chrome, Firefox, and Safari return appName "Netscape".

Chrome, Firefox, IE, Safari, and Opera all return appCodeName "Mozilla".

The Browser Engine

The property product returns the engine name of the browser:

Example


<id="demo"></p>

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

The Browser Version I

The property appVersion returns version information about the browser:


Example


<id="demo"></p>

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

 

The Browser Version II

The property userAgent also returns version information about the browser:


Example

<id="demo"></p>

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

Warning !!!


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

Different browsers can use the same name

The navigator data can be changed by the browser owner

Some browsers misidentify themselves to bypass site tests

Browsers cannot report new operating systems, released later than the browser


The Browser Platform

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


Example


<id="demo"></p>

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

The Browser Language

The property language returns the browser's language:


Example


<id="demo"></p>

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

Is Java Enabled?

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


Example


<id="demo"></p>

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

 

Comments

Popular posts from this blog

JavaScript Array Methods

JavaScript Arrays JavaScript arrays are used to store multiple values in a single variable. Displaying Arrays In this tutorial we will use a script to display arrays inside a <p> element with id="demo": Example < p  id= "demo" > < /p > < script > var cars = ["Saab", "Volvo", "BMW"]; document.getElementById("demo").innerHTML = cars; < /script > The first line (in the script) creates an array named cars. The second line "finds" the element with id="demo", and "displays" the array in the "innerHTML" of it. Example var cars = ["Saab", "Volvo", "BMW"]; Spaces and line breaks are not important. A declaration can span multiple lines: Example var cars = [     "Saab",     "Volvo",     "BMW" ]; Never put a comma after the last element (like &