# Namespace goog.userAgent

code »
Show:Public Protected Private

## Global Functions

code »goog.userAgent.compare ( v1, v2 ) ⇒ `number`
Deprecated: Use goog.string.compareVersions.

Compares two version numbers.

Parameters
v1: `string` Version of first item. v2: `string` Version of second item.
Returns
1 if first argument is higher 0 if arguments are equal -1 if second argument is higher.

code »goog.userAgent.determinePlatform_ ( ) ⇒ `string`

Returns
the platform (operating system) the user agent is running on. Default to empty string because navigator.platform may not be defined (on Rhino, for example).

code »goog.userAgent.determineVersion_ ( ) ⇒ `string`

Returns
The string that describes the version number of the user agent.

code »goog.userAgent.getDocumentMode_ ( ) ⇒ `(number|undefined)`

Returns
Returns the document mode (for testing).

code »goog.userAgent.getNavigator ( ) ⇒ `Object`

Returns
The native navigator object.

code »goog.userAgent.getUserAgentString ( ) ⇒ `?string`

Returns the userAgent string for the current browser. Some user agents (I'm thinking of you, Gears WorkerPool) do not expose a navigator object off the global scope. In that case we return null.

Returns
The userAgent string or null if there is none.

code »goog.userAgent.initPlatform_ ( )

Initialize the goog.userAgent constants that define which platform the user agent is running on.

code »goog.userAgent.init_ ( )

Initializer for goog.userAgent. This is a named function so that it can be stripped via the jscompiler option for stripping types.

code »goog.userAgent.isDocumentMode ( version ) ⇒ `boolean`

Deprecated alias to `goog.userAgent.isDocumentModeOrHigher`.

Parameters
version: `number` The version to check.
Returns
Whether the IE effective document mode is higher or the same as the given version.

code »goog.userAgent.isDocumentModeOrHigher ( documentMode ) ⇒ `boolean`

Whether the IE effective document mode is higher or the same as the given document mode version. NOTE: Only for IE, return false for another browser.

Parameters
documentMode: `number` The document mode version to check.
Returns
Whether the IE effective document mode is higher or the same as the given version.

code »goog.userAgent.isVersion ( version ) ⇒ `boolean`
Deprecated: Use goog.userAgent.isVersionOrHigher().

Deprecated alias to `goog.userAgent.isVersionOrHigher`.

Parameters
version: `(string|number)` The version to check.
Returns
Whether the user agent version is higher or the same as the given version.

code »goog.userAgent.isVersionOrHigher ( version ) ⇒ `boolean`

Whether the user agent version is higher or the same as the given version. NOTE: When checking the version numbers for Firefox and Safari, be sure to use the engine's version, not the browser's version number. For example, Firefox 3.0 corresponds to Gecko 1.9 and Safari 3.0 to Webkit 522.11. Opera and Internet Explorer versions match the product release number.

Parameters
version: `(string|number)` The version to check.
Returns
Whether the user agent version is higher or the same as the given version.

## Global Properties

code »goog.userAgent.ANDROID : `boolean`

Whether the user agent is running on Android.

code »goog.userAgent.BROWSER_KNOWN_ : `boolean`

Whether we know the browser engine at compile-time.

code »goog.userAgent.DOCUMENT_MODE : `(number|undefined)`

For IE version < 7, documentMode is undefined, so attempt to use the CSS1Compat property to see if we are in standards mode. If we are in standards mode, treat the browser version as the document mode. Otherwise, IE is emulating version 5.

code »goog.userAgent.GECKO : `boolean`

Whether the user agent is Gecko. Gecko is the rendering engine used by Mozilla, Mozilla Firefox, Camino and many more.

code »goog.userAgent.IE : `boolean`

Whether the user agent is Internet Explorer. This includes other browsers using Trident as its rendering engine. For example AOL and Netscape 8

code »goog.userAgent.IPAD : `boolean`

Whether the user agent is running on an iPad.

code »goog.userAgent.IPHONE : `boolean`

Whether the user agent is running on an iPhone.

code »goog.userAgent.LINUX : `boolean`

Whether the user agent is running on a Linux operating system.

code »goog.userAgent.MAC : `boolean`

Whether the user agent is running on a Macintosh operating system.

code »goog.userAgent.MOBILE : `boolean`

Whether the user agent is running on a mobile device.

code »goog.userAgent.OPERA : `boolean`

Whether the user agent is Opera.

code »goog.userAgent.PLATFORM : `string`

The platform (operating system) the user agent is running on. Default to empty string because navigator.platform may not be defined (on Rhino, for example).

code »goog.userAgent.PLATFORM_KNOWN_ : `boolean`
code »goog.userAgent.SAFARI : `boolean`
Deprecated: Use `goog.userAgent.product.SAFARI` instead. TODO(nicksantos): Delete this from goog.userAgent.

Used while transitioning code to use WEBKIT instead.

code »goog.userAgent.VERSION : `string`

The version of the user agent. This is a string because it might contain 'b' (as in beta) as well as multiple dots.

code »goog.userAgent.WEBKIT : `boolean`

Whether the user agent is WebKit. WebKit is the rendering engine that Safari, Android and others use.

code »goog.userAgent.WINDOWS : `boolean`

Whether the user agent is running on a Windows operating system.

code »goog.userAgent.X11 : `boolean`

Whether the user agent is running on a X11 windowing system.

code »goog.userAgent.detectedAndroid_ : `boolean`

Whether the user agent is running on Android.

code »goog.userAgent.detectedGecko_ : `boolean`

Whether the user agent string denotes Gecko. Gecko is the rendering engine used by Mozilla, Mozilla Firefox, Camino and many more.

code »goog.userAgent.detectedIPad_ : `boolean`

Whether the user agent is running on an iPad.

code »goog.userAgent.detectedIPhone_ : `boolean`

Whether the user agent is running on an iPhone.

code »goog.userAgent.detectedIe_ : `boolean`

Whether the user agent string denotes Internet Explorer. This includes other browsers using Trident as its rendering engine. For example AOL and Netscape 8

code »goog.userAgent.detectedLinux_ : `boolean`

Whether the user agent is running on a Linux operating system.

code »goog.userAgent.detectedMac_ : `boolean`

Whether the user agent is running on a Macintosh operating system.

code »goog.userAgent.detectedMobile_ : `boolean`

Whether the user agent string denotes a mobile device.

code »goog.userAgent.detectedOpera_ : `boolean`

Whether the user agent string denotes Opera.

code »goog.userAgent.detectedWebkit_ : `boolean`

Whether the user agent string denotes WebKit. WebKit is the rendering engine that Safari, Android and others use.

code »goog.userAgent.detectedWindows_ : `boolean`

Whether the user agent is running on a Windows operating system.

code »goog.userAgent.detectedX11_ : `boolean`

Whether the user agent is running on a X11 windowing system.

code »goog.userAgent.isVersionOrHigherCache_ : `{}`

Cache for `goog.userAgent.isVersionOrHigher`. Calls to compareVersions are surprisingly expensive and, as a browser's version number is unlikely to change during a session, we cache the results.

## Compiler Constants

code »goog.userAgent.ASSUME_ANDROID : `boolean`
code »goog.userAgent.ASSUME_ANY_VERSION : `boolean`
code »goog.userAgent.ASSUME_GECKO : `boolean`
code »goog.userAgent.ASSUME_IE : `boolean`
code »goog.userAgent.ASSUME_IPAD : `boolean`
code »goog.userAgent.ASSUME_IPHONE : `boolean`
code »goog.userAgent.ASSUME_LINUX : `boolean`
code »goog.userAgent.ASSUME_MAC : `boolean`
code »goog.userAgent.ASSUME_MOBILE_WEBKIT : `boolean`
code »goog.userAgent.ASSUME_OPERA : `boolean`
code »goog.userAgent.ASSUME_WEBKIT : `boolean`
code »goog.userAgent.ASSUME_WINDOWS : `boolean`
code »goog.userAgent.ASSUME_X11 : `boolean`