Last active
December 15, 2015 05:59
-
-
Save cristianferrarig/5212996 to your computer and use it in GitHub Desktop.
Add class "retina" in HTML tag for high pixel ratio devices
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
// jQuery mode | |
if (window.devicePixelRatio > 1) { | |
$('body').addClass('retina'); | |
} | |
// Only javascript mode | |
if (window.devicePixelRatio > 1) { | |
var elHtml = document.getElementsByTagName('html')[0]; | |
var atrClass = elHtml.getAttribute('class'); | |
atrClass = atrClass + ' retina'; | |
elHtml.setAttribute('class', atrClass); //For Most Browsers | |
//elHtml.setAttribute('className', atrClass); //For IE; harmless to other brow | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment