首先需要得到设备像素比/设备分辨率(根据下面设备表去判断)
/*
iPhone 3GS3.5吋320x480@1x320x480
iPhone 4/4s3.5吋320x480@2x640x960
iPhone 5/5s/5c4.0吋320x568@2x640x1136
iPhone 64.7吋375x667@2x750x1334
iPhone 6Plus5.5吋414x736@3x1242x2208
iPhone 6s4.7吋375x667@2x750x1334
iPhone 6sPlus5.5吋414x736@3x1242x2208
iPhone 74.7吋375x667@2x750x1334
iPhone 7Plus5.5吋414x736@3x1242x2208
iPhone 84.7吋375x667@2x750x1334
iPhone 8Plus5.5吋414x736@3x1242x2208
iPhone X5.8吋375x812@3x1125x2436
iPhone XS5.8吋375x812@3x1125x2436
iPhone XS Max6.5吋414x896@3x1242x2688
iPhone XR6.1吋414x896@2x828x1792
*/
判断:
// iPhone 4/4s
var iPhone4 = window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 320 && window.screen.height === 480
// iPhone 5/5s/5c
var iPhone5 = window.devicePixelRatio && window.devicePixelRatio === 2 && window.screen.width === 320 && window.screen.height === 568
//iPhone 6 ...
//if(iPhone4){alert('iPhone 4/4s')}else if(iphone5){alert('iPhone 5/5s/5c ')}