从jQuery中检测iPhone [英] Detecting the iPhone from jQuery

查看:135
本文介绍了从jQuery中检测iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I know browser-detection is supposed to be taboo, but I'm out of ideas.

我有一个网站,我想要很好和完整 - 在全尺寸计算机上运行时使用,在iPhone(或其他智能手机)上使用简单。在这里做什么是正确的?

I have a website that I want to be nice and full-featured when running on a full-sized computer and simple to use when on an iPhone (or other smart phone). What's the right thing to do here?

推荐答案

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

you can do it with simple javascript

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

这篇关于从jQuery中检测iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆