문제

I can check if the user is using a mobile device, and I can check if the user is using mobile safari. But how I can I check which specific type of mobile iDevice the user is using?

도움이 되었습니까?

해결책

var matchiDevice = new RegExp("i[p|P](hone|ad|od)");
var iDeviceTest = matchiDevice.exec(navigator.userAgent);

if (iDeviceTest != null) {
    var iDevice = iDeviceTest[0];
    alert("You are using a " + iDevice + "!");
}
else 
{
    alert("You are not using an iDevice!");
}

This will tell you whether or not it's an iDevice, and which one.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top