【问题标题】:Safari browser tags for iPhone and iPadiPhone 和 iPad 的 Safari 浏览器标签
【发布时间】:2012-05-23 13:10:16
【问题描述】:

有没有办法确定访问网站的 Safari 浏览器是在 iPhone 还是 iPad 上运行?我不想在 iPad 上加载移动网站

【问题讨论】:

    标签: browser safari


    【解决方案1】:

    我没试过,但这似乎是正确的:

    if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod'))
    {
        header('Location: http://yoursite.com/iphone');
        exit();
    }
    

    这个网站也有一个 javascript 例子: http://davidwalsh.name/detect-iphone

    如需更详细的解释,您可能会发现此博客很有趣:

    http://www.bionicworks.com/php/detect-ipads-safari-browser-and-redirect-to-html5-page

    【讨论】:

    • 我已经使用了那个 php,它按预期工作。另外,我的JS版本是:var iphone = ((window.navigator.userAgent.match('iPhone'))||(window.navigator.userAgent.match('iPod')))?true:false; var ipad = (window.navigator.userAgent.match('iPad'))?true:false;,然后设置window.location=somepage.html,根据哪个是真的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-25
    相关资源
    最近更新 更多