Skip to content

Instantly share code, notes, and snippets.

@samrayner
Created March 17, 2012 12:55
Show Gist options
  • Save samrayner/2058607 to your computer and use it in GitHub Desktop.
Save samrayner/2058607 to your computer and use it in GitHub Desktop.
Serve splash images for iPhone/iPad models
(function () {
var width = 320; //default to non-retina iPhone
var height = 460;
if(navigator.platform === 'iPad') {
if(window.orientation === 90 || window.orientation === -90) {
width = 1024; //landscape
height = 748;
}
else {
width = 768; //portrait
height = 1004;
}
}
if(window.devicePixelRatio === 2) {
width *= 2;
height *= 2;
}
document.write('<link rel="apple-touch-startup-image" href="images/splash-'+width+'x'+height+'.png"/>' );
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment