【问题标题】:ontouch function not being fired on iPhone simulatoriPhone模拟器上没有触发ontouch功能
【发布时间】:2011-06-08 23:54:30
【问题描述】:

在 iPhone 模拟器上,ontouch 的事件回调似乎不起作用。

以下内容似乎不适用于我的模拟器:

document.ontouch = function() {
    alert('it works!');
}

虽然这确实返回 true:

if ('ontouch' in document) {
    alert('touch supported');
}

还有其他人遇到过这个问题吗?

【问题讨论】:

    标签: javascript ios dom-events ios-simulator iphone-4


    【解决方案1】:

    有 3 个与触摸相关的事件:

    1. ontouchstart
    2. ontouchmove
    3. ontouchend

    用这些试试,应该没问题!

    可以在这篇文章中找到一些很好的例子:

    http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/

    【讨论】:

      猜你喜欢
      • 2020-05-26
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-26
      • 1970-01-01
      相关资源
      最近更新 更多