Created
October 27, 2010 19:52
-
-
Save johnhunter/649819 to your computer and use it in GitHub Desktop.
Set browser forking classes on the html element
This file contains 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
/* | |
Set browser forking classes on html element. Can be executed as soon as jQuery is loaded. | |
@dependency jQuery 1.4 | |
flags are: webkit, opera, msie, mozilla, (safari flag not used), os-win, os-mac | |
*/ | |
(function(flags, app) { | |
$.each($.browser, function(k, v) { | |
if (v === true && k !== 'safari') flags.push(k); | |
}); | |
os('Win', 'os-win'); | |
os('Mac', 'os-mac'); | |
os('NT 5.1', 'os-xp'); | |
os('NT 6.0', 'os-vista'); | |
os('NT 6.1', 'os-win7'); | |
window.browserFlags = $('html').addClass(flags.join(' ')).attr('class'); | |
function os (s, f) { if (app.indexOf(s) !== -1) flags.push(f); } | |
})([], String(navigator && navigator.appVersion)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated to include various versions of Windows.