Script ua.js (Deprecated) — Practical Browser Sniffing Script
Please note that this script is deprecated and is not recommended for general use. If you have scripts which currently depend upon ua.js, you may continue to use it however it is recommended you replace your browser detection strategy.
xbDetectBrowser() is called when the script ua.js is loaded. It sets several properties on the window.navigator object which detail the kind of browser being used as based upon the reported navigator.userAgent string.
Please note that Object based sniffing is preferrable in most cases to using detection based upon the navigator.userAgent string. Many browsers, Gecko and Opera for example, can be configured to report any User Agent String. Opera even changes the DOM they support depending upon whether the user has set their User Agent string to an IE compatible setting. In addition, Object based sniffing will support any Browser which supports the approprioate objects while User Agent string based sniffing will only detect specific browsers.
However, there are situations, for example when you need to distinguish between versions of the same browser, where User Agent string based sniffing is appropriate.
Please see xbDOM for an example of Object based sniffing.
Example 1. Basic Example
"win" for all Windows platforms
"mac" for all Macintosh platforms
"nix" for all Unix like platforms
"" if platform is not one of the above
"opera" for Opera based browsers
"netscape" for Netscape browsers
"microsoft" for Microsoft browsers
"compuserve" for Compuserve browsers
"sun" for HotJava
"" if organization is not one of the above
If the browser organization is one of the above, then the version will be reported in navigator.version as a floating point number. Otherwise, the version will be 0. Note that Gecko based browser will report the Release Version from the UserAgent string and not actual version reported by the vendor.
navigator.family contains a string that groups browsers into families that can be reasonably treated in a similar fashion. Different versions of a browser within a family can be distinguished by the navigator.version property. Current families that are detected are:
"hotjava" HotJava browsers from Sun
"opera" Opera Browsers
"ie3" Internet Explorer versions before 4
"ie4" Internet Explorer versions 4 and later
"gecko" browsers based upon the Mozilla Open Source browser such as Netscape 6
"nn3" Netscape Navigator 3.x browsers
"nn4" Netscape Navigator 4.x browsers
"aol" AOL browsers