userAgent Property

Internet Development Index

Retrieves a string equivalent to the HTTP user-agent request header.


[ sUserAgent = ] object.userAgent

Possible Values

sUserAgentString that specifies a valid HTTP user agent.

The property is read-only. The property has no default value.


The HTTP user-agent request header contains information about compatibility, the browser, and the platform name. For more information about the browser, see the appName property. For more information about the platform, see the appVersion property.

The userAgent property dynamically returns a different value depending on the browser and platform versions. For example, Microsoft® Internet Explorer 6 returns the following string for Microsoft Windows® XP.

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)


This example uses the userAgent property to specify a required platform before additional script is executed. For example, if Windows XP is a requirement for the document, you can use a variable to determine whether the user is running the necessary operating system. The "bIsXP" variable is set to true if Windows XP is found in the userAgent value and the additional script is processed.

var bIsXP=false;
function fnInit(){
if(navigator.userAgent.indexOf("Windows NT 5.1")>-1){
// Process additional script.

Standards Information

There is no public standard that applies to this property.

Applies To

clientInformation, navigator

See Also

About Conditional Comments