DOM:window.navigator.userAgent
From MDC
Contents |
[edit] Summary
Returns the user agent string for the current browser.
[edit] Syntax
var ua = window.navigator.userAgent;
[edit] Value
ua stores the user agent string value of the current browser.
The window.navigator.userAgent property is read-write; it has no default value.
The user agent string is built on a formal structure which can be decomposed into several pieces of info. Each of these pieces of info comes from other navigator properties which are also settable by the user. Gecko-based browsers comply with the following general structure:
userAgent = appCodeName/appVersion number (Platform; Security; OS-or-CPU; Localization; rv: revision-version-number) product/productSub Application-Name Application-Name-version
[edit] Example
alert(window.navigator.userAgent) // alerts "Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.2) Gecko/20010725 Netscape6/6.1"
[edit] Notes
Browser identification based on detecting the user agent string is unreliable and is not recommended, as the user agent string is user configurable. For example:
- Mozilla Suite and Firefox can use the preference "general.useragent.override" in about:config. Some Firefox extensions or multi-bar do that.
- Opera 6+ allows users to set the browser identification string via a menu
- Microsoft Internet Explorer uses the Windows registry
- Safari and iCab allow users to change the browser user agent string to predefined Internet Explorer or Netscape strings via a menu.
[edit] Specification
DOM Level 0. Not part of any standard.