Navigator.UserAgent

Originally published on June 1, 2003.
Last updated on June 24, 2016.

It is not necessary to specify window before the navigator.userAgent object. Either window.navigator.userAgent or navigator.userAgent will produce the same result.

JavaScript Example

<script>// <![CDATA[
    document.write(navigator.userAgent);
// ]]></script>

PHP Example

<?php
    echo $_SERVER['HTTP_USER_AGENT'];
?>
CCBot/2.0 (http://commoncrawl.org/faq/)

Parsing the UserAgent String


Leave a Reply