Navigator userAgent Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Navigator

Description

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>
<html>
<body>

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

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

<script>
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;
}
</script>

</body>
</html>

Related Tutorials