Skip to content

Instantly share code, notes, and snippets.

@dvschultz
Created November 7, 2013 20:02
Show Gist options
  • Save dvschultz/7360953 to your computer and use it in GitHub Desktop.
Save dvschultz/7360953 to your computer and use it in GitHub Desktop.
ibooks javascript to determine which device you’re using ibooks on #eprdctn
$(document).ready(function() {
(function(){
//cache variables
var iw = $('html').width(),
wh = screen.height;
alert('screen height: '+ wh +', inner-width: ' + iw);
if (wh == 768 || wh == 1024) {
if ( (iw == 567) || (iw == 858) ) $('body').addClass('ibooks-ipad');
} else if (wh == 320 || wh == 480 || wh == 568) {
if ( (iw == 270) || (iw == 460) ) $('body').addClass('ibooks-iphone');
} else {
$('body').addClass('ibooks-desktop');
}
})();
});
@dvschultz
Copy link
Author

Here’s how I then test this in CSS to be sure its working

.ibooks-ipad {
  background-color: red;
}

.ibooks-iphone {
  background-color: green;
}

.ibooks-desktop {
  background-color: orange;
}

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