Name

userAgent — NN 2 IE 3 DOM n/a

Synopsis

Read-only

Information about the browser software, including version, operating system platform, and brand. This is the most complete set of information about the browser, whereas appVersion and appName properties provide subset data. Typical data for this property looks like the following:

Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)

Do not rely on the length or position of any part of this data, as it may vary with browser, version, and proxy server used at the client end. Instead, use the indexOf( ) method to check for the presence of a desired string.

Example

if (navigator.userAgent.indexOf("MSIE") != -1) {
    var isIE = true
}

Value

String.

Default

Depends on browser.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.