检测并通过JavaScript从Android手机差异化的Android平板? [英] Detect and differentiate Android Tablet from Android Phone via JavaScript?
问题描述
我见过<一个href=\"http://stackoverflow.com/questions/7173642/detecting-whether-android-device-is-a-phone-or-a-tablet-with-javascript\">Detecting无论Android设备是电话或使用javascript 的平板电脑,但我想,因为它似乎对答案节中描述的方法是不一致的知道,如果出现了这样做的任何更新,更稳定的方式。
I have seen Detecting whether Android device is a phone or a tablet with javascript but I want to know if there has been any newer, more stable way to do this as it seems the method described on the answer section is inconsistent.
基本上,我有一个网站,我有一个Android应用的,但我只想提醒那些谁是在移动设备上,因为我想显示完整的网站平板电脑用户。
Basically, I have a website that I have an Android app for but I only want to alert those who are on mobile devices as I want to show the full site to tablet users.
推荐答案
另一种方法是通过屏幕宽度/高度去。片毕竟是比手机大。
Another method would be to go by screen width/height. Tablets are larger than phones after all.
例如,如果你知道你正在处理要么是Android手机/平板电脑检查 screen.width
属性。
For example, if you know you're dealing with either an android phone / tablet check the screen.width
property.
如果你有兴趣参加,其中一些片剂可以有更大的分辨率优势,这种方法特别有用。并不是所有的平板电脑将拥有毕竟更大的屏幕。
This method can be particularly useful if you're interested in taking advantage of larger resolutions which some tablets may have. Not all tablets will have a larger screen after all.
我建议不要使用用户代理。它们是依赖于该用户当前正在使用的浏览器。
I'd advise against using User Agents. They're dependant on the browser which the user is currently using.
这篇关于检测并通过JavaScript从Android手机差异化的Android平板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!