Window navigator.userAgent Property
- Previous Page taintEnabled()
- Next Page appCodeName
- Go to the Previous Level Window Navigator
Definition and Usage
userAgent
The property returns the user-agent header sent by the browser to the server.
userAgent
The property is read-only.
The returned value contains information about the browser name, version, and platform.
The Web规范建议浏览器应提供尽可能少的标头信息。永远不要假设这个属性在未来的浏览器中会保持不变。
Instance
Example 1
Get navigator.userAgent:
let agent = navigator.userAgent;
Example 2
Display all navigator properties:
let text = "<p>Browser CodeName: " + navigator.appCodeName + "</p>" + "<p>Browser Name: " + navigator.appName + "</p>" + "<p>Browser Version: " + navigator.appVersion + "</p>" + "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>" + "<p>Browser Language: " + navigator.language + "</p>" + "<p>Browser Online: " + navigator.onLine + "</p>" + "<p>Platform: " + navigator.platform + "</p>" + "<p>User-agent header: " + navigator.userAgent + "</p>";
Syntax
navigator.userAgent
Return Value
Type | Description |
---|---|
String | Browser User-Agent Header. |
Browser Support
All Browsers Support navigator.userAgent
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page taintEnabled()
- Next Page appCodeName
- Go to the Previous Level Window Navigator