Skip to content

Instantly share code, notes, and snippets.

@defmech
Created February 16, 2017 11:28
Show Gist options
  • Save defmech/1d493865396454642eff106cf1a114e9 to your computer and use it in GitHub Desktop.
Save defmech/1d493865396454642eff106cf1a114e9 to your computer and use it in GitHub Desktop.
function iPhoneVersion() {
var iHeight = window.screen.height;
var iWidth = window.screen.width;
if (iWidth === 320 && iHeight === 480) {
return "4";
}
else if (iWidth === 375 && iHeight === 667) {
return "6";
}
else if (iWidth === 414 && iHeight === 736) {
return "6+";
}
else if (iWidth === 320 && iHeight === 568) {
return "5";
}
else if (iHeight <= 480) {
return "2-3";
}
return 'none';
}
function isIphone() {
return !!navigator.userAgent.match(/iPhone/i);
}
if ( isIphone() && iPhoneVersion() === "6"){
//code..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment