如何在Firefox Mobile (Android, Fennec 7.0.1)中检测触摸支持

How to detect touch support in Firefox Mobile (Android, Fennec 7.0.1)

本文关键字:检测 支持 触摸 Fennec Firefox Mobile Android      更新时间:2023-09-26

Fennec 7.0.1似乎支持触摸事件,但已知的方法如

var hasTouch = 'ontouchstart' in window

和Modernizr。触摸检测支持失败。这个

window.ontouchstart = handler

无论如何都会生成事件。

我如何检测功能支持?

我也试过这些http://modernizr.github.com/Modernizr/touch.html

我相信测试TouchEvent in window应该有效。

如果做不到这一点,测试document instanceof DocumentTouch在此刻肯定会起作用。从Firefox 9开始,"ontouchstart" in window将做正确的事情,所以在这一点上,您不关心DocumentTouch是否继续存在。