【问题标题】:How to detect touch support in Firefox Mobile (Android, Fennec 7.0.1)如何检测 Firefox Mobile 中的触摸支持(Android,Fennec 7.0.1)
【发布时间】:2011-10-26 23:55:48
【问题描述】:

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

var hasTouch = 'ontouchstart' in window

Modernizr.touch 无法检测到支持。这个

window.ontouchstart = handler

无论如何都会产生事件。

我怎样才能检测到支持?

我也试过这些 http://modernizr.github.com/Modernizr/touch.html 他们都报告错误。

【问题讨论】:

    标签: javascript android html firefox


    【解决方案1】:

    我相信测试TouchEvent in window 应该可以工作。

    如果做不到这一点,测试document instanceof DocumentTouch 目前肯定会起作用。从 Firefox 9 开始,"ontouchstart" in window 会做正确的事情,所以到那时你不在乎DocumentTouch 是否会继续存在。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    • 1970-01-01
    • 1970-01-01
    • 2022-10-02
    • 2021-04-23
    • 2013-07-05
    • 1970-01-01
    相关资源
    最近更新 更多