Navigator userAgent Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Navigator


The userAgent property returns the user-agent header sent by the browser to the server.

The user-agent header contains information about the name, version and platform of the browser.

This property is read-only.

Return Value

A String, representing the user agent string for the current browser

The user-agent header sent by your browser is:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from w w  w  .  ja  va  2  s .c o m*/
    var x = "User-agent header sent: " + navigator.userAgent;
    document.getElementById("demo").innerHTML = x;


Related Tutorials