#

API Docs for: 3.10.3
Show: Inherited Protected Private Deprecated

# UA Class

Defined in: `yui/js/yui-ua.js:9`
Module: yui-base
Parent Module: yui

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.

- Index
- Methods
- Properties

## Item Index

### Methods

- compareVersions
- parseUA static

### Properties

- accel static
- air
- android static
- caja
- chrome static
- gecko static
- ie static
- ios static
- ipad static
- iphone static
- ipod static
- mobile static
- nodejs static
- opera static
- os static
- phantomjs
- safari static
- secure static
- silk static
- touchEnabled static
- userAgent static
- webkit static
- webos static
- winjs static

## Methods

### `compareVersions`

(

- `a`
- `b`

)

Defined in `yui/js/yui-ua.js:459`

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:

- `a` Number | String

  First version number to compare.

- `b` Number | String

  Second version number to compare.

#### Returns:

-1 if a is lower than b, 0 if they're equivalent, 1 if a is higher than b.

### `parseUA`

(

- `[subUA=navigator.userAgent]`

)
Object static

Defined in `yui/js/yui-ua.js:25`

Static method on `YUI.Env` for parsing a UA string. Called at instantiation to populate `Y.UA`.

#### Parameters:

- `[subUA=navigator.userAgent]` String optional

  UA string to parse

#### Returns:

Object: The Y.UA object

## Properties

### `accel`

Boolean static

Defined in `yui/js/yui-ua.js:196`

Detects Kindle Silk Acceleration

### `air`

Float

Defined in `yui/js/yui-ua.js:139`

Adobe AIR version number or 0. Only populated if webkit is detected. Example: 1.0

### `android`

Float static

Defined in `yui/js/yui-ua.js:182`

Detects Googles Android OS version

### `caja`

Float

Defined in `yui/js/yui-ua.js:211`

Google Caja version number or 0.

### `chrome`

Float static

Defined in `yui/js/yui-ua.js:118`

Chrome will be detected as webkit, but this property will also be populated with the Chrome version number

### `gecko`

Float static

Defined in `yui/js/yui-ua.js:65`

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   <-- Reports 1.7
    Firefox 1.5.0.9: 1.8.0.9 <-- 1.8
    Firefox 2.0.0.3: 1.8.1.3 <-- 1.81
    Firefox 3.0   <-- 1.9
    Firefox 3.5   <-- 1.91

### `ie`

Float static

Defined in `yui/js/yui-ua.js:49`

Internet Explorer version number or 0. Example: 6

### `ios`

Boolean static

Defined in `yui/js/yui-ua.js:174`

General truthy check for iPad, iPhone or iPod

Default: null

### `ipad`

Float static

Defined in `yui/js/yui-ua.js:153`

Detects Apple iPad's OS version

### `iphone`

Float static

Defined in `yui/js/yui-ua.js:160`

Detects Apple iPhone's OS version

### `ipod`

Float static

Defined in `yui/js/yui-ua.js:167`

Detects Apples iPod's OS version

### `mobile`

String static

Defined in `yui/js/yui-ua.js:127`

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

Defined in `yui/js/yui-ua.js:235`

The Nodejs Version

Default: 0

### `opera`

Float static

Defined in `yui/js/yui-ua.js:57`

Opera version number or 0. Example: 9.2

### `os`

String static

Defined in `yui/js/yui-ua.js:226`

The operating system. Currently only detecting windows or macintosh

Default: null

### `phantomjs`

Float

Defined in `yui/js/yui-ua.js:146`

PhantomJS version number or 0. Only populated if webkit is detected. Example: 1.0

### `safari`

Float static

Defined in `yui/js/yui-ua.js:109`

Safari will be detected as webkit, but this property will also be populated with the Safari version number

### `secure`

Boolean static

Defined in `yui/js/yui-ua.js:218`

Set to true if the page appears to be in SSL

### `silk`

Float static

Defined in `yui/js/yui-ua.js:189`

Detects Kindle Silk

### `touchEnabled`

Boolean static

Defined in `yui/js/yui-ua.js:250`

Are touch/msPointer events available on this device

### `userAgent`

String static

Defined in `yui/js/yui-ua.js:267`

The User Agent string that was parsed

### `webkit`

Float static

Defined in `yui/js/yui-ua.js:82`

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.1 <-- Reports 312.8 -- currently the
                                      latest available for Mac OSX 10.3.
    Safari 2.0.2:         416     <-- hasOwnProperty introduced
    Safari 2.0.4:         418     <-- preventDefault fixed
    Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
                                      different versions of webkit
    Safari 2.0.4 (419.3): 419     <-- Tiger installations that have been
                                      updated, but not updated
                                      to the latest patch.
    Webkit 212 nightly:   522+    <-- Safari 3.0 precursor (with native
    SVG and many major issues fixed).
    Safari 3.0.4 (523.12) 523.12  <-- First Tiger release - automatic
    update from 2.x via the 10.4.11 OS patch.
    Webkit nightly 1/2008:525+    <-- Supports DOMContentLoaded event.
                                      yahoo.com user agent hack removed.

http://en.wikipedia.org/wiki/Safariversionhistory

### `webos`

Float static

Defined in `yui/js/yui-ua.js:203`

Detects Palms WebOS version

### `winjs`

Boolean static

Defined in `yui/js/yui-ua.js:243`

Window8/IE10 Application host environment