How to Detect Browser (and browser version) using JavaScript

Browser (and browser version) detection is an “all time classic” development requirement. jQuery.browser WAS an excellent solution, but it was removed in jQuery 1.9.

Actually, it would be better to try to detect a browser feature instead of browser name itself, where possible. An ideal solution for this is Modernizr (a JavaScript library that detects HTML5 and CSS3 features in the user’s browser).

But, if you still need to detect browser and browser version (using javascript), I suggest the following solutions (among many others): Bowser – A Browser detector and Browser detect provided by quirksmode. I prefer the first one.

Bowser – A Browser detector

Get bowser from Add it to your document with something like this (change /url/to/… with the real url):

<script type="text/javascript" src="/url/to/bowser.min.js"></script>


The HTML part

Let’s create these links for demo:

        Click to <a id="detect_browser"
              href="javascript:void(0);">Detect browser properties</a>

        Click to <a id="detect_version"
              href="javascript:void(0);">Detect browser version</a>


Remark: I use jQuery to handle events, but you can use plain javascript (if you prefer).

<script type="text/javascript">

        $(function() {

                // detect browser properties
                $("#detect_browser").click(function() {
                        alert(JSON.stringify(bowser, null, '    '));

                // detect browser version
                $("#detect_version").click(function() {




Suggested javascript solutions for browser detection

From jQuery docs

Browser Feature detection solutions