Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created August 23, 2012 08:17
Show Gist options
  • Save netsi1964/3434201 to your computer and use it in GitHub Desktop.
Save netsi1964/3434201 to your computer and use it in GitHub Desktop.
javascript: Simple browser detection
// @netsi1964 23/08-2012: Simple browser detection
// Requires jQuery
// Will add browser name and version to HTML tag as class
// For instance: html.mozilla v14
var $html = jQuery('html');
jQuery.each(jQuery.browser, function(i, val) {
if (typeof val==='boolean' && !$html.hasClass(i)) $html.addClass(i);
});
var version = 'v'+parseInt(jQuery.browser.version);
if (!$html.hasClass(version)) $html.addClass(version);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment