JavaScript Window Navigator
- Previous Page JS History
- Next Page JS Pop-up Boxes
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>
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>
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>
"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>
Browser Version
appVersion
The property returns information about the browser version:
Example
<p id="demo"></p> <script> document.getElementById("demo").innerHTML = navigator.appVersion; </script>
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>
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>
Browser Language
language
The property returns the browser language:
Example
<p id="demo"></p> <script> document.getElementById("demo").innerHTML = navigator.language; </script>
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>
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>
- Previous Page JS History
- Next Page JS Pop-up Boxes