navigator object
Contains information about the browser and the operating system of the user.
Most members of the navigator object return information about the version of browser, and the platform running the browser.
The clientInformation object is an alias for the navigator object, but if you need cross-browser functionality use the navigator object.
The clientInformation object is an alias for the navigator object, but if you need cross-browser functionality use the navigator object.
Syntax:
Properties that reference the object:
| window.navigator |
The base interface, through which you can add new functionalities to the navigator object, is the Navigator interface.
Possible members:
Properties:
Retrieves the code name of the browser. | ||||||||||||
Returns the minor version of the browser. | ||||||||||||
Returns the name of the browser. | ||||||||||||
Returns the platform and version of the browser. | ||||||||||||
Returns the language of the browser application or the operating system's user interface. | ||||||||||||
Retrieves the build identifier of the browser. | ||||||||||||
Retrieves a Boolean value that indicates whether cookies are enabled in the browser. | ||||||||||||
Returns the central processing unit (CPU) class of the user's operating system. | ||||||||||||
Returns the language of the browser application. | ||||||||||||
Represents a collection of all supported MIME types. | ||||||||||||
Returns a Boolean value that indicates whether the browser is working online. | ||||||||||||
Returns a string that contains information about the user's operating system and the central processing unit (CPU). | ||||||||||||
Returns the name of the operating system platform. | ||||||||||||
Represents a collection of all installed plugins in the browser. | ||||||||||||
Returns a string that contains information about the browser engine. | ||||||||||||
Returns a string that contains information about the development build number of the browser engine. | ||||||||||||
Returns the language edition of the operating system. | ||||||||||||
Returns a string value that represents the user-agent header. | ||||||||||||
Returns the current Regional and Language settings of the operating system in Internet Explorer and the language of the browser application in Opera. | ||||||||||||
|
Contains information about the current user's profile. | |||||||||||
Returns a string that specifies the name of the browser vendor. | ||||||||||||
Returns a string that specifies the version number of the browser given by the vendor. |
Methods:
javaEnabled | Returns a Boolean value that indicates whether Java is enabled in the current browser. | |||||||||||
preference | Gets or sets a user preference. Only available in privileged code. | |||||||||||
registerContentHandler | Allows registering a web site as a possible handler for content of the specified MIME type. | |||||||||||
registerProtocolHandler |
|
Allows registering a web site as a possible handler for a protocol. | ||||||||||
taintEnabled | Returns a Boolean value that indicates whether the data-tainting security model is enabled. |
Example HTML code 1:
This example shows how to detect the user's browser:
|
||||
<head> <script type="text/javascript"> function DetectBrowser () { var agent = navigator.userAgent.toLowerCase (); var browser = "Unknown browser"; if (agent.search ("msie") > -1) { browser = "Internet Explorer"; } else { if (agent.search ("firefox") > -1) { browser = "Firefox"; } else { if (agent.search ("opera") > -1) { browser = "Opera"; } else { if (agent.search ("safari") > -1) { if (agent.search ("chrome") > -1) { browser = "Google Chrome"; } else { browser = "Safari"; } } } } } alert (browser); } </script> </head> <body> <button onclick="DetectBrowser ();">Detect Browser!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example displays various information about the browser and the operating system of the user:
|
||||
<head> <script type="text/javascript"> function AddRowToInfo (description, value) { if (value !== undefined) { var infoTable = document.getElementById ("info"); var row = infoTable.insertRow (-1); var cell = row.insertCell (-1); cell.innerHTML = description; cell.style.paddingRight = "10px"; cell = row.insertCell (-1); cell.innerHTML = value; cell.style.paddingLeft = "10px"; } } function GetVisitorInfo () { AddRowToInfo ("Name of the browser (appName)", window.navigator.appName); AddRowToInfo ("Name of the browser vendor (vendor)", window.navigator.vendor); AddRowToInfo ("Code name of the browser (appCodeName)", window.navigator.appCodeName); AddRowToInfo ("Engine of the browser (product)", window.navigator.product); AddRowToInfo ("Build number of the browser engine (productSub)", window.navigator.productSub); if (window.opera) { AddRowToInfo ("Build number of the browser (buildNumber)", window.opera.buildNumber ()); AddRowToInfo ("Version number of the browser (version)", window.opera.version ()); } AddRowToInfo ("Version and platform of the browser (appVersion)", window.navigator.appVersion); AddRowToInfo ("Version of the browser given by the vendor (vendorSub)", window.navigator.vendorSub); AddRowToInfo ("Minor version of the browser (appMinorVersion)", window.navigator.appMinorVersion); AddRowToInfo ("Build identifier of the browser (buildID)", window.navigator.buildID); AddRowToInfo ("User-agent request header (userAgent)", window.navigator.userAgent); AddRowToInfo ("Language of the browser (language)", window.navigator.language); AddRowToInfo ("Cookies are enabled (cookieEnabled)", window.navigator.cookieEnabled); AddRowToInfo ("Operating system (platform)", window.navigator.platform); if (window.navigator.language === undefined) { // in Opera, the language, browserLanguage and userLanguage properties are equivalent AddRowToInfo ("Language of the operating system's user interface (browserLanguage)", window.navigator.browserLanguage); AddRowToInfo ("Regional and Language settings of the operating system (userLanguage)", window.navigator.userLanguage); } AddRowToInfo ("Language of the installed operating system (systemLanguage)", window.navigator.systemLanguage); AddRowToInfo ("Class of CPU (cpuClass)", window.navigator.cpuClass); AddRowToInfo ("Information about the OS and CPU (oscpu)", window.navigator.oscpu); AddRowToInfo ("System is online (onLine)", window.navigator.onLine); } </script> </head> <body onload="GetVisitorInfo ();"> <table id="info" cellpadding="0px" cellspacing="0px" border="1px" style="empty-cells:show;"> <colgroup> <col style="background-color: #e0a0b0;" /> <col /> </colgroup> <tbody> </tbody> </table> </body> |
||||
|
||||
Did you find this example helpful?
|
Related pages:
External links:
User Contributed Comments