Get navigator.userAgent:
let agent = navigator.userAgent;
Try it Yourself »
More "Try it Yourself" examples below.
The userAgent
property returns the user-agent header sent by the browser to the server.
The userAgent
property is read-only.
The value returned, contains information about the browser name, version and platform.
The web specification suggests that browsers should provide as little header information as possible. Never assume that this property will stay unchanged in future browsers.
navigator.userAgent
Type | Description |
A string | The browser user agent header. |
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>";
Try it Yourself »
navigator.userAgent
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!