简体   繁体   English

如何判断浏览器是否在具有JavaScript的触摸屏设备上?

[英]How do I tell whether a browser is on a touchscreen device with JavaScript?

I know this is a bit of perennial question, but here goes: I want to know whether the device my site is being accessed with is a touchscreen. 我知道这是一个长期存在的问题,但是现在来看:我想知道访问我的网站的设备是否是触摸屏。 That means phones and iPads, of course, which are individually detectable, but also other touchscreens that may well be running flavors of Windows. 当然,这意味着可以单独检测到的电话和iPad,但也可能运行Windows风格的其他触摸屏。 Any chance of determining the presence or absence of a mouse on those? 是否有机会确定在这些鼠标上是否存在鼠标?

Let's say I'm willing to use a large JavaScript library like Modernizr . 假设我愿意使用像Modernizr这样的大型JavaScript库。 Will that help any? 这会有所帮助吗?

You might want to look into MobileESP . 您可能需要研究MobileESP Not touchscreens only, but it at least gives you some detection capabilities. 不仅是触摸屏,它还至少为您提供了一些检测功能。 From their page: 从他们的页面:

The MobileESP project seeks to provide web site developers an easy-to-use and lightweight API for detecting whether visitors are using a mobile device, and if so, what kind. MobileESP项目旨在为网站开发人员提供易于使用且轻巧的API,以检测访问者是否正在使用移动设备,如果使用,则使用哪种设备。 The APIs provide simple boolean results for popular individual device OS categories (such as iPhone, BlackBerry, Symbian S60, and Windows Mobile), device capabilities (eg, J2ME), and broad classes of devices, such as "iPhone Tier" (iPhone/Android/WebOS) and smartphones. 这些API为流行的单个设备操作系统类别(例如iPhone,BlackBerry,Symbian S60和Windows Mobile),设备功能(例如J2ME)以及各种设备类别(例如“ iPhone层”(iPhone / iPhone / Android / WebOS)和智能手机。

尝试http://wurfl.sourceforge.net/获取设备功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 css 或 javascript 在触摸屏设备上制作多级下拉菜单? - How do I make a multi-level dropdown menu work on a touchscreen device using css or javascript? 如何使用Javascript来判断浏览器是否更改了HTML输入字段? - How can I use Javascript to tell whether an HTML input field has been changed by the browser? 使用Javascript,如何检测浏览器是否在平板电脑设备上与手机上运行? - Using Javascript, how can I detect whether the browser is running on a tablet device vs a phone? 如何判断“我的页面上是否存在 Javascript object”? - How can I tell 'Whether a Javascript object exists on my page'? 如何判断ReactJS是否处于JavaScript开发模式? - How can I tell whether ReactJS is in development mode from JavaScript? 如何判断字母是否在字符串中-javascript - How to tell whether a letter is in a string-javascript 如何判断Javascript错误是否为“阻止”? - How to tell whether a Javascript error is 'blocking'? Javascript:如何判断AJAX响应是否为JSON - Javascript: How to tell whether AJAX response is JSON 如何确定设备是否为桌面浏览器? - How do I determine if a device is a desktop browser? 如何判断用户是否使用 Brave 作为浏览器? - How do I tell if a user is using Brave as their browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM