触摸事件在Safari for iOS上双击

时间:2014-04-07 20:19:18

标签: android ios html5 safari touch

我们有一个使用Bootstrap,Angular和MongoDB构建的webapp,它运行在带有express的NodeJS上。站点的一部分上有一个图像,可响应该图像上的触摸或鼠标事件。每次触摸(或鼠标点击)开始和结束时都会调用javascript函数。实现此目的的代码是:

            <div class="visible-sm visible-md visible-lg">
                <div class="col-xs-4 nopadding">
                    <p class="noheightgap">
                    <a class="img-responsive">
                        <img id="1" onmousedown="BeginClick(event);" onmouseup="EndClick(event);"
                             ontouchstart="BeginTouch(event);" ontouchend="EndTouch(event);" src="../public/img/Custom-1.png" class="img-responsive img-rounded">
                    </a>
                    </p>
                </div>
            </div>

此代码可在我们测试过的所有桌面浏览器以及Android Chrome浏览器上正常运行。但是,在iPhone上使用Safari,或在Android上使用Dolphin HD浏览器时,似乎ontouchstart和ontouchend方法都会被触发两次。 (触及时间更长)我们从未看到过两组以上的事件被触发。在所有情况下,我们都在使用

event.preventDefault(); 

防止恶意事件发生。有什么东西可能会导致iPhone上的Safari和Android上的Dolphin多次触发触摸事件?

0 个答案:

没有答案