English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Navigator userAgent Property

JavaScript Navigator Object

userAgentA read-only property that returns the user agent string that the browser sends to the server-The value of the 'agent' header.

Syntax:

navigator.userAgent
var x = navigator.userAgent;
document.querySelector("#output").innerHTML = x;
Test and See‹/›

Browser compatibility

All browsers fully support the userAgent property:

Property
userAgentYesYesYesYesYes

Technical details

Return value:A string representing the current browser's user agent string

More examples

This example displays all Navigator properties:

var txt = "";
txt += "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt += "<p>Browser Name: " + navigator.appName + "</p>";
txt += "<p>Browser Version: " + navigator.appVersion + "</p>";
txt += "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt += "<p>Browser Language: " + navigator.language + "</p>";
txt += "<p>Browser Online: " + navigator.onLine + "</p>";
txt += "<p>Platform: " + navigator.platform + "</p>";
txt += "<p>User-agent header: " + navigator.userAgent + "</p>";
document.write(txt);
Test and See‹/›

Related References

Navigator Reference:navigator.appCodeName property

Navigator Reference:navigator.appname property

Navigator Reference:navigator.cookieEnabled property

Navigator Reference:navigator.language property

Navigator Reference:navigator.onLine property

Navigator Reference:navigator.product property

JavaScript Navigator Object