UA Class
YUI user agent detection. Do not fork for a browser if it can be avoided. Use feature detection when you can. Use the user agent as a last resort. For all fields listed as @type float, UA stores a version number for the browser engine, 0 otherwise. This value may or may not map to the version number of the browser using the engine. The value is presented as a float so that it can easily be used for boolean evaluation as well as for looking for a particular range of versions. Because of this, some of the granularity of the version info may be lost. The fields that are @type string default to null. The API docs list the values that these fields can have.
Item Index
Methods
- compareVersions
- parseUA static
Methods
compareVersions
    
        - 
                    
                        a
- 
                    
                        b
Performs a simple comparison between two version numbers, accounting for standard versioning logic such as the fact that "535.8" is a lower version than "535.24", even though a simple numerical comparison would indicate that it's greater. Also accounts for cases such as "1.1" vs. "1.1.0", which are considered equivalent.
Returns -1 if version a is lower than version b, 0 if they're equivalent, 1 if a is higher than b.
Versions may be numbers or strings containing numbers and dots. For example,
both 535 and "535.8.10" are acceptable. A version string containing
non-numeric characters, like "535.8.beta", may produce unexpected results.
Parameters:
Returns:
Properties
air
    Float
    
    
    
    
    
    Adobe AIR version number or 0. Only populated if webkit is detected. Example: 1.0
android
    Float
    
    
    
    
        static
    
    
    Detects Googles Android OS version
caja
    Float
    
    
    
    
    
    Google Caja version number or 0.
chrome
    Float
    
    
    
    
        static
    
    
    Chrome will be detected as webkit, but this property will also be populated with the Chrome version number
gecko
    Float
    
    
    
    
        static
    
    
    Gecko engine revision number. Will evaluate to 1 if Gecko is detected but the revision could not be found. Other browsers will be 0. Example: 1.8
Firefox 1.0.0.4: 1.7.8   
    ie
    Float
    
    
    
    
        static
    
    
    Internet Explorer version number or 0. Example: 6
ios
    Float
    
    
    
    
        static
    
    
    General truthy check for iPad, iPhone or iPod
Default: null
ipad
    Float
    
    
    
    
        static
    
    
    Detects Apple iPad's OS version
iphone
    Float
    
    
    
    
        static
    
    
    Detects Apple iPhone's OS version
ipod
    Float
    
    
    
    
        static
    
    
    Detects Apples iPod's OS version
mobile
    String
    
    
    
    
        static
    
    
    The mobile property will be set to a string containing any relevant user agent information when a modern mobile browser is detected. Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series devices with the WebKit-based browser, and Opera Mini.
Default: null
nodejs
    Float
    
    
    
    
        static
    
    
    The Nodejs Version
Default: 0
opera
    Float
    
    
    
    
        static
    
    
    Opera version number or 0. Example: 9.2
safari
    Float
    
    
    
    
        static
    
    
    Safari will be detected as webkit, but this property will also be populated with the Safari version number
silk
    Float
    
    
    
    
        static
    
    
    Detects Kindle Silk
webkit
    Float
    
    
    
    
        static
    
    
    AppleWebKit version. KHTML browsers that are not WebKit browsers will evaluate to 1, other browsers 0. Example: 418.9
Safari 1.3.2 (312.6): 312.8.1http://en.wikipedia.org/wiki/Safariversionhistory
webos
    Float
    
    
    
    
        static
    
    
    Detects Palms WebOS version
