Skip to content

Instantly share code, notes, and snippets.

@defmech
Created February 16, 2017 11: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 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