从jQuery中检测iPhone

Mal*_*lio 2 iphone jquery

我知道浏览器检测应该是禁忌,但我没有想法.

我有一个网站,我想在一台全尺寸的电脑上运行时很好,功能齐全,在iPhone(或其他智能手机)上使用简单.这里做什么是正确的?

Sen*_*kin 12

你可以用简单的javascript做到这一点

function isiPhone(){
    return (
        (navigator.platform.indexOf("iPhone") != -1) ||
        (navigator.platform.indexOf("iPod") != -1)
    );
}
if(isiPhone()){
   alert('iPhone detected');
}
Run Code Online (Sandbox Code Playgroud)