The original version of the Apple series, but the idea of conversion, first to infer whether it is an apple, and then use the resolution to obtain the model
Get Phone model function begin
function Getphonetype () {
Regular, ignoring uppercase and lowercase
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
Phone Touch Event starts
<script>
function Load () {
Document.addeventlistener (' Touchstart ', touch, false);
Document.addeventlistener (' Touchmove ', touch, false);
Document.addeventlistener (' touchend ', touch, false);
function Touch (event) {
var event = Event | | window.event;
var oinp = document.getElementById ("InP");
Switch (event.type) {
Case "Touchstart":
oinp.innerhtml = "Touch started (" + Event.touches[0].clientx + "," + Event.touches[0].clienty + ")";
Break
Case "Touchend":
oinp.innerhtml = "<br>touch End (" + Event.changedtouches[0].clientx + "," + Event.changedtouches[0].clienty + ")";
Break
Case "Touchmove":
Event.preventdefault ();
oinp.innerhtml = "<br>touch moved (" + Event.touches[0].clientx + "," + Event.touches[0].clienty + ")";
Break
}
}
}
Window.addeventlistener (' Load ', load, false);
</script>
Touch Event Ended
The simplest in history, JS and get the phone model