为什么Mobiledetect.net脚本检测不到iPhone? [英] why does Mobiledetect.net script not detect iPhone?

查看:372
本文介绍了为什么Mobiledetect.net脚本检测不到iPhone?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用这个脚本来检测设备 http://mobiledetect.net/
但它没有检测到iPhone。

I am trying to detect the device using this script http://mobiledetect.net/ but it's not detecting iPhone.

的header.php:

<?php
require_once 'include/Mobile_Detect.php';
$detect = new Mobile_Detect; ?>

device.php:

<?php include 'include/header.php'; ?>
<?php if( $detect->isMobile() && $detect->isTablet() ){ ?>
<script type='text/javascript'> 
    alert("I am mobile");
</script>
<?php } else { ?>
<script type='text/javascript'> 
    alert("I am desktop");
</script>
<? } ?>

当我查看页面上的桌面我收到弹出此消息:我的桌面 - 正如我所料

When I check the page on desktop I am getting popup with this message: I am desktop - As I expected

当我检查Android平板电脑我收到弹出此消息的页面:我的移动 - 正如我所料

When I check the page on android tablet I am getting popup with this message: I am mobile - As I expected

当我检查iPhone上的网页我收到弹出此消息:我的桌面 - 未如预期

When I check the page on iPhone I am getting popup with this message: I am desktop - NOT as expected.

这是为什么?

下面是页面

推荐答案

你问的浏览器是否在移动设备上运行(安培;&安培;)在平板电脑上:

You're asking whether the browser is running on a mobile device and (&&) on a tablet:

$ detect-&GT; isMobile()及和放大器; $ detect-&GT; isTablet()

由于第二个条件,这是仅用于片剂,不是电话真。只是,如果你想的条件是真的删除任何移动设备:

Due to the second condition, this is only true for tablets, not for phones. Just remove it if you want the condition to be true for any mobile device:

&LT;如果PHP($ detect-&GT; isMobile()){&GT;

这篇关于为什么Mobiledetect.net脚本检测不到iPhone?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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