JavaScript Window Navigator


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


Window Navigator

window.navigatorThis object can be written without using the window prefix.

Examples

<script> txt = "<p>Browser code:" + navigator.appCodeName + "</p>"; txt+= "<p>Browser name:" + navigator.appName + "</p>"; txt+= "<p>Browser version:" + navigator.appVersion + "</p>"; txt+= "<p>Cookies enabled:" + navigator.cookieEnabled + "</p>"; txt+= "<p>Hardware platform:" + navigator.platform + "</p>"; txt+= "<p>User agent:" + navigator.userAgent + "</p>"; txt+= "<p>User agent language:" + navigator.language + "</p>"; document.getElementById("example").innerHTML=txt; </script>

Try it Yourself »


Warning!!!

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

  • The navigator data can be changed by browser users.
  • Some browsers may misidentify test sites.
  • Browsers cannot report operating systems newer than the browser's release.

Browser Detection

Since navigator can mislead browser detection, object detection can be used to sniff out different browsers.

Since different browsers support different objects, you can use objects to detect browsers. For example, because only Opera supports the property "window.opera", you can identify Opera based on this.

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

Other Extensions