goog.userAgent
Functions
compare( v1, v2 ) → number
number
getNavigator() → (Object|null)
(Object|null)
TODO(nnaze): Change type to "Navigator" and update compilation targets.
Parameters | None. | ||
---|---|---|---|
Returns |
|
getNavigatorTyped() → (Navigator|null)
(Navigator|null)
Parameters | None. | ||
---|---|---|---|
Returns |
|
getUserAgentString() → string
string
Returns the userAgent string for the current browser.
Parameters | None. | ||
---|---|---|---|
Returns |
|
isDocumentMode( version ) → boolean
boolean
isDocumentModeOrHigher( documentMode ) → boolean
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 |
| ||||
---|---|---|---|---|---|
Returns |
|
isVersionOrHigher( version ) → boolean
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 |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
See Also |
Properties
ANDROID → boolean
boolean
Whether the user agent is running on Android.
EDGE → boolean
boolean
Whether the user agent is Microsoft Edge (EdgeHTML based).
EDGE_OR_IE → boolean
boolean
Whether the user agent is MS Internet Explorer or MS Edge (EdgeHTML based).
GECKO → boolean
boolean
Whether the user agent is Gecko. Gecko is the rendering engine used by Mozilla, Firefox, and others.
IE → boolean
boolean
Whether the user agent is Internet Explorer.
IOS → boolean
boolean
Whether the user agent is running on iOS.
IPAD → boolean
boolean
Whether the user agent is running on an iPad.
IPHONE → boolean
boolean
Whether the user agent is running on an iPhone.
IPOD → boolean
boolean
Whether the user agent is running on an iPod.
KAIOS → boolean
boolean
Whether the user agent is running on KaiOS.
LINUX → boolean
boolean
Whether the user agent is running on a Linux operating system.
Note that goog.userAgent.LINUX considers ChromeOS to be Linux, while goog.labs.userAgent.platform considers ChromeOS and Linux to be different OSes.
MAC → boolean
boolean
Whether the user agent is running on a Macintosh operating system.
MOBILE → boolean
boolean
Whether the user agent is running on a mobile device.
TODO(nnaze): Consider deprecating MOBILE when labs.userAgent is promoted as the gecko/webkit logic is likely inaccurate.
OPERA → boolean
boolean
Whether the user agent is Presto-based Opera.
PLATFORM → string
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).
SAFARI → boolean
boolean
Used while transitioning code to use WEBKIT instead.
warning Deprecated | Use |
---|
VERSION → string
string
The version of the user agent. This is a string because it might contain 'b' (as in beta) as well as multiple dots.
WEBKIT → boolean
boolean
Whether the user agent is WebKit. WebKit is the rendering engine that Safari, Edge Chromium, Opera Chromium, Android and others use.
WINDOWS → boolean
boolean
Whether the user agent is running on a Windows operating system.
X11 → boolean
boolean
Whether the user agent is running on a X11 windowing system.
Compiler Constants
goog.userAgent.ASSUME_ANDROID → boolean
boolean
Whether the user agent is running on Android.
goog.userAgent.ASSUME_ANY_VERSION → boolean
boolean
Whether the
goog.userAgent.isVersionOrHigher
function will return true for any version.
goog.userAgent.ASSUME_EDGE → boolean
boolean
Whether we know at compile-time that the browser is EDGE, referring to EdgeHTML based Edge.
goog.userAgent.ASSUME_GECKO → boolean
boolean
Whether we know at compile-time that the browser is GECKO.
goog.userAgent.ASSUME_IE → boolean
boolean
Whether we know at compile-time that the browser is IE.
goog.userAgent.ASSUME_IPAD → boolean
boolean
Whether the user agent is running on an iPad.
goog.userAgent.ASSUME_IPHONE → boolean
boolean
Whether the user agent is running on an iPhone.
goog.userAgent.ASSUME_IPOD → boolean
boolean
Whether the user agent is running on an iPod.
goog.userAgent.ASSUME_KAIOS → boolean
boolean
Whether the user agent is running on KaiOS.
goog.userAgent.ASSUME_LINUX → boolean
boolean
Whether the user agent is running on a Linux operating system.
goog.userAgent.ASSUME_MAC → boolean
boolean
Whether the user agent is running on a Macintosh operating system.
goog.userAgent.ASSUME_MOBILE_WEBKIT → boolean
boolean
Whether we know at compile-time that the browser is a mobile device running WebKit e.g. iPhone or Android.
goog.userAgent.ASSUME_OPERA → boolean
boolean
Whether we know at compile-time that the browser is OPERA, referring to Presto-based Opera.
goog.userAgent.ASSUME_WEBKIT → boolean
boolean
Whether we know at compile-time that the browser is WEBKIT.
goog.userAgent.ASSUME_WINDOWS → boolean
boolean
Whether the user agent is running on a Windows operating system.
goog.userAgent.ASSUME_X11 → boolean
boolean
Whether the user agent is running on a X11 windowing system.