检测网络上的移动浏览器? [英] Detecting mobile browsers on the web?
本文介绍了检测网络上的移动浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很想知道如何检查iPhone,iPad和其他移动浏览器。(JavaScript或CSS)
I'm curious to know how to check for iPhone, iPad and other mobile browsers.(JavaScript or CSS)
编辑:
请不是用户代理字符串。这可能是假的。
Not user agent string, please. That can be faked.
可能的Dupes:
- 自动检测移动浏览器(通过用户代理?)和
- Auto detect mobile browser (via user-agent?) and
- Standard way to detect mobile browsers in a web application based on the http request
推荐答案
基本上你检查用户代理字符串
Basically you check the User Agent String
参见 http://www.hand-interactive.com/resources/detect-mobile-javascript.htm
检测iPhone:
navigator.userAgent.toLowerCase().search("iphone") > -1
通常,功能检测优于浏览器检测,最好知道用户的浏览器可以做比他正在使用的。 Modernizer 是一个很好的工具。
In general feature detection is better than browser detection it is better to know what the user's browser can do than what he's using. Modernizer is a good tool for that.
这篇关于检测网络上的移动浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Auto detect mobile browser (via user-agent?) and
查看全文