Sometimes, we want to get the user agent with JavaScript.
In this article, we’ll look at how to get the user agent with JavaScript.
How to get the user agent with JavaScript?
To get the user agent with JavaScript, we use the navigator.userAgent
property.
For instance, we write
<input type="text" id="UserAgent">
to add an input.
Then we write
document.getElementById('UserAgent').value = navigator.userAgent;
to put the user agent value into the input with navigator.userAgent
.
Conclusion
To get the user agent with JavaScript, we use the navigator.userAgent
property.