Created
August 23, 2012 08:17
-
-
Save netsi1964/3434201 to your computer and use it in GitHub Desktop.
javascript: Simple browser detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @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