Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript Window Navigator

JavaScript Window Navigator


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


Window Navigator

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

Example

<script txt=">

Browser code name:

"

navigator

.

appCodeName

"

"

;

txt

+=

"

Browser name:

"

navigator

.

appName

"

"

;

txt

+=

"

Browser version:

"

navigator

.

appVersion

"

"

;

txt

+=

"

Cookies enabled:

"

navigator

.

cookieEnabled

"

"

;

txt

+=

"

Hardware platform:

"

navigator

.

platform

"

"

;

txt

+=

"

User agent:

"

navigator

.

userAgent

"

"

;

txt

+=

"

User agent language:

"

navigator

.

language

"

"

;

document

.

getElementById

(

"

example

"

)

.

innerHTML

=

txt

;

script

Try it »


Warning!!!

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


Browser detection

Since navigator can mislead browser detection, 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...}