Categories
JavaScript Answers

How to get the user agent with JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.