how to get share code of an profile facebook | webserver debian 8 | testing


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() {



If you need help on JSON.stringify, read this post.


Using the above code:

Click to Detect browser properties

Click to Detect browser version


Suggested javascript solutions for browser detection

From jQuery docs

Browser Feature detection solutions

Sign-up for our free email newsletter. Get updates when new tutorials and tips are published. You can unsubscribe anytime with a click.

Your comments are welcomed!

This site actively encourages commenting on any post. Comments are not pre-moderated, but this community does not tolerate direct or indirect attacks, name-calling or insults. Please, read terms of use and Comment Policy at privacy policy.

More tips