JavaScript : Detecting the Visitor's Browser
Contents ]
Sékine Coulibaly

Browser, Tell Me Your Age!

Knowing the version of the browser is also useful. For instance, some versions support style sheets while other don't. To obtain this information, we will use the appVersion function of the navigator object.

But there is a snag: the appVersion property does not return just one piece of information, but gives you browser version, language, operating system. In our example, we are only interested in the browser version. To get what we need, we use the parseFloat function which can retrieve numbers contained in any string:

function Version(){
    return parseFloat(navigator.appVersion)}

To display the browser version on a page, just copy the following lines in your code where it suits you:

<script>
document.write("Version: " + parseFloat(navigator.appVersion));
</script>