PhoneGap的2.4.0与Android 4.2 - 奇怪的双击行为 [英] Phonegap 2.4.0 with Android 4.2 - strange double click behaviour
问题描述
我使用PhoneGap的2.4.0创建Android和iOS应用程序。
I'm using phonegap 2.4.0 to create an Android and iOS App.
现在我认识到,在链接的onclick事件的Android应用程序内触发了两次采用了Android 4.2.2的Nexus 4设备上,如双击(althoug我拍了拍它只有一次!)。
Now I recognized that the onclick event in links is fired twice inside the Android App using Android 4.2.2 on a Nexus 4 device, like a double click (althoug I tapped it only once!).
<a href="#" onclick="$(this).append('test'); return false;" style="some styles...">some text</a>
在使用的库:
- 的jQuery 1.9.1
- 在jQuery Mobile的1.3.0(RC)
- 在jQuery UI的1.10.0
- 在jQuery的触摸打孔0.2.2
- 在PhoneGap的2.4.0
在我点击(或抽头)的链接我的Nexus 4(安卓4.2.2)将字符串测试在应用程序中追加了两次。
After I clicked (or tapped) the link on my Nexus 4 (Android 4.2.2) the string 'test' is appended twice inside the app.
当我测试它作为移动web应用程序直接在Android浏览器,这不会发生。
This does NOT happen when I test it as mobile web app directly in the android browser.
这也适用于我的三星S3(安卓4.1.2)里面的应用程序。 在iPhone没问题了。
It also works on my Samsung S3 (Android 4.1.2) inside the app. No problem on iPhones, too.
任何人都认可这种奇怪的行为? (也许能解决这个问题?;-))
Anyone else recognized this strange behavior? (and maybe was able to fix it? ;-) )
推荐答案
使用从治标不治本 scirra.com
last_click_time = new Date().getTime();
document.addEventListener('click', function (e) {
click_time = e['timeStamp'];
if (click_time && (click_time - last_click_time) < 1000) {
e.stopImmediatePropagation();
e.preventDefault();
return false;
}
last_click_time = click_time;
}, true);
这篇关于PhoneGap的2.4.0与Android 4.2 - 奇怪的双击行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!