Javascript Browser Navigator userAgent Property

Introduction

The user-agent header sent by your browser is:

var x = "User-agent header sent: " + navigator.userAgent;

Click the button to display the user-agent header sent by the browser to the server.

View in separate window

<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Test</button>

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

<script>
function myFunction() {/*from  w  ww.j a va  2 s  . co  m*/
  var x = "User-agent header sent: " + navigator.userAgent;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

The value returned, contains information about the name, version and platform of the browser.

This property is read-only.

The userAgent property returns a String representing the user agent string for the current browser.




PreviousNext

Related