Skip to content

Instantly share code, notes, and snippets.

@mauryaratan
Last active December 10, 2015 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauryaratan/4350979 to your computer and use it in GitHub Desktop.
Save mauryaratan/4350979 to your computer and use it in GitHub Desktop.
Add body classes for browser, OS and retina display support.
$(function() {
var browser, classList, os, platform, retina;
retina = window.devicePixelRatio > 1 ? "retina" : "no-retina";
platform = window.navigator.userAgent;
if (/Chrome/.test(platform)) {
browser = "chrome";
} else if (/Firefox/.test(platform)) {
browser = "firefox";
} else {
browser = "unknown-browser";
}
if (/Mac/.test(platform)) {
os = "mac";
} else if (/Windows/.test(plaform)) {
os = "windows";
} else {
os = "unknown-os";
}
classList = os + " " + browser + " " + retina;
$("body").addClass(classList);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment