Originally can not get the Apple series model, but switch ideas, first determine whether it is Apple, and then use the resolution to obtain the model
Get Phone model function begin
function Getphonetype () {
Regular, ignoring case
var pattern_phone = new RegExp ("iphone", "I");
var pattern_android = new RegExp ("Android", "I");
var useragent = Navigator.userAgent.toLowerCase ();
var isandroid = pattern_android.test (useragent);
var isiphone = pattern_phone.test (useragent);
var phonetype= "Phonetype";
if (isandroid) {
var zh_cnindex = Useragent.indexof ("-");
var spaceindex = useragent.indexof ("Build", zh_cnindex+4);
var fullresult = useragent.substring (Zh_cnindex,spaceindex);
Phonetype=fullresult.split (";") [1];
}else if (isiphone) {
6 w=375 6plus w=414 5s w=320 5 w=320
var wigth = Window.innerwidth | | Document.documentElement.clientWidth | | Document.body.clientWidth;
if (wigth>400) {
Phonetype = "Iphone6 plus";
}else if (wigth>370) {
Phonetype = "Iphone6";
}else if (wigth>315) {
Phonetype = "iphone5 or iphone5s";
}else{
Phonetype = "iphone 4s";
}
}else{
Phonetype = "Your device is too advanced";
}
return phonetype;
}
End
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The simplest in history, JS and get the phone model