javascript或css3 media query如何检测来访设备是iPad Mini

 n_light征蓝妙 发布于 2022-11-25 07:10

iPad Mini发布了,按照以往的方法通过javascript的window.navigator检测,但是返回内容和iPad 2是一样的。

Mini的PPI比9.7寸的高了不少,所以同样像素的元素在Mini上物理尺寸小了不少,我希望能通过检测从而调用不同的CSS改变这些尺寸的大小,不知道大家有什么好方法?

补充UserAgent
Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A406 Safari/8536.2
3 个回答
  • 如果只是用不同的CSS改变这些尺寸的大小 media query能行吧

    2022-11-25 07:19 回答
  • 目前根据userAgent确实是无法区分的。下面这篇文章考虑了各种技术,最后得出的结论是:Impossible。

    To make a final conclusion, the problem is not that we can’t detect iPad mini; the problem is that we can’t detect its unique features, such as density and real dimensions that are important for delivering the best possible experience one ach device using responsive web design techniques.

    Mission: Impossible – iPad mini detection for HTML5:http://www.mobilexweb.com/blog/ipad-m...
    Hacker News-No user agent detection for the iPad Mini:http://news.ycombinator.com/item?id=4...

    2022-11-25 07:19 回答
  • iPad mini的分辨率和iPad1和iPad2都是一样的 1024*768,所以前端的元素都是一样的
    要区分iPad mini只有通过http header里的UA来判断

    <script> 
    alert(navigator.userAgent);
    </script>
    2022-11-25 07:19 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有