Retrieves a string equivalent to the HTTP user-agent request header.
dhtml语法
[ sUserAgent = ] object.userAgent
DHTML可能的值
sUserAgent | Stringthat specifies a valid HTTP user agent. |
The property is read-only.
The property has no default value.
Remarks
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)
Examples
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.
<SCRIPT>
var bIsXP=false;
window.onload=fnInit;
function fnInit(){
if(navigator.userAgent.indexOf("Windows NT 5.1")>-1){
bIsXP=true;
}
if(bIsXP==true){
// Process additional script.
}
}
</SCRIPT>
是否符合公共标准
There is no public standard that applies to this property.
Applies To
更多语法参考
About Conditional Comments