Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created October 27, 2010 19:52
Show Gist options
  • Save johnhunter/649819 to your computer and use it in GitHub Desktop.
Save johnhunter/649819 to your computer and use it in GitHub Desktop.
Set browser forking classes on the html element
/*
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));
@johnhunter
Copy link
Author

Updated to include os forking.

@johnhunter
Copy link
Author

Updated to include various versions of Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment