Easy Tutorial
❮ Jsref Class Static Obj Window ❯

JavaScript Window Navigator


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


Window Navigator

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

Example

<script>
txt = "<p>Browser Code Name: " + 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>

Warning!!!

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


Browser Detection

Due to the potential for misleading browser detection with navigator, object detection can be used to sniff different browsers.

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

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

❮ Jsref Class Static Obj Window ❯