【发布时间】:2019-09-13 22:39:30
【问题描述】:
我使用这样的触摸屏设备检测:
if (window.navigator.maxTouchPoints || 'ontouchstart' in document)
// handle as mobile device
else
// handle as desktop
当我在 Chrome 移动仿真中更改屏幕时,maxTouchPoints 和 'ontouchstart' in document 的结果都无法预测。
对于同一个模拟屏幕,它可能返回 maxTouchPoints 等于 0 或 1,'ontouchstart' in document 等于 true 或 false。
所以,我真的不能做这张支票。
您能推荐一种解决此问题的方法吗?
【问题讨论】:
-
听起来像一个错误,所以也许你可以在crbug.com 上报告它。至于解决方案,我建议使用真正的模拟器应用程序,并通过网络使用 ADB 将您的桌面 Chrome 连接到其移动 Chrome(它是内置的,或者有启用它的移动应用程序)。
标签: javascript google-chrome-devtools touch emulation