javascript 在 Ipad Safari 上启用快速(双击?)点击

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5894806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 18:43:25  来源:igfitidea点击:

Enable quicks (double?) clicks on Ipad Safari

javascriptjqueryipadsafariclick

提问by user739476

I'm building a HTML/JavaScript interface in which I would need some reactivity and so, the possibility for users to click really fast on the same button on the page.

我正在构建一个 HTML/JavaScript 界面,在该界面中我需要一些反应性,因此用户可以非常快速地单击页面上的同一按钮。

I disabled the doubleclick/zoom on the iPad thanks to the <meta name="viewport" content="user-scalable=no" />, but then, if I double click or click too fast on the buttons, it does nothing.

由于 ,我禁用了 iPad 上的双击/缩放功能<meta name="viewport" content="user-scalable=no" />,但是,如果我双击或在按钮上单击速度过快,则它什么也不做。

I'm using jQuery and tried the dblclick event, didn't work.

我正在使用 jQuery 并尝试了 dblclick 事件,但没有用。

回答by jorgenfb

You can try using the doubletap pluginwhich enable the use of "doubletap" events on iPhone and iPad devices.

您可以尝试使用doubletap 插件,它可以在 iPhone 和 iPad 设备上使用“doubletap”事件。

回答by Bobbi Bennett

I gave up on this, rolled my own inside my 'touchstart - move - touchend' sequence. Its horrible, but, inside my touchend, I have :

我放弃了这个,在我的“touchstart - move - touchend”序列中滚动我自己的。它很可怕,但是,在我的触摸端中,我有:

if (swipeMoving==0) {
swipeStarted = 0;
tapco +=1;
if (tapco==2) doDblClick();
window.setTimeout(function(){ tapco=0; }, 700);
return;
}

If you want click, too, put it in a delay, and cancel if the second click comes.

如果你也想点击,把它延迟,如果第二次点击就取消。

回答by Mandeep Pasbola

Use this script to use double click in Ipad. http://code.google.com/p/jquery-ui-for-ipad-and-iphone/

使用此脚本在 Ipad 中使用双击。 http://code.google.com/p/jquery-ui-for-ipad-and-iphone/

Alternative :-

选择 :-

As click on the desktop browser is equivalent to the touch on the Ipad. So, the double click will be equivalent to the click on the Ipad.

因为在桌面浏览器上点击就相当于在Ipad上点击。因此,双击将等同于在 Ipad 上的单击。

To implement this :

要实现这一点:

if((navigator.userAgent.match(/iPad/i))){
    $(".element").click(function () {/*run the code*/ });
}
else {
    $(".element").dblclick(function () {/*run the code*/ });
}

Hope it helps.

希望能帮助到你。