本文介绍了Google FastButton在iOS上点击两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 使用 MrMaksimize和Alex Blacks实施时.google.com / mobile / articles / fast_buttonsrel =nofollow> Google FastButton 我在iOS中获得两次点击。 试试这个小提琴: http://jsfiddle.net/Cotten/zQsVZ/ var a = new FastButton(document.getElementById('a'),function(){ alert('click'); }); < div id =a>首先点击我< / div> < div id =b>然后,点击此处,不会发生任何事情......但确实如此:(< / div> 放大结果窗格 点击绿色按钮,显示警告 按好,一切都很好 然后点击红色或蓝色div,它们没有FastButton(..) 再次触发警报:( 我在iPhone 4S iOS 6和iPad 3上使用iOS时出现这种错误行为5.1。 在Android上它似乎有效。 我得到了与 jquery.tappable.js 。 谢谢! 我遇到了同样的问题,因为我认为问题可能在于你正在使用并发出警报(就像我以前那样)。出于某种原因(我没有深入研究代码),由于警报而导致另一个事件被触发。如果您只是尝试输出代码,请使用console.log,它是非阻塞而不是警报,您可能会看到第二个事件未被调用。 希望这个想法不是使用alert命令,但是如果是,请使用超时,这可以解决ghostclick的实现,我认为这无论如何都会打破这种行为: new FastButton(document.getElementById('a'),function(){ setTimeout('alert(hello);', 500); }); 希望有所帮助。 干杯, Miguel When using MrMaksimize and Alex Blacks implementation of Google FastButton I get two clicks in iOS.Try this fiddle: http://jsfiddle.net/Cotten/zQsVZ/var a = new FastButton(document.getElementById('a'), function() { alert('click');});<div id="a">First click me</div><div id="b">Then, click here and nothing should happen... but it does :(</div>zoom in on the results paneclick the green button, which shows an alertpress ok, everything looks finethen click the red or the blue div, which do not have the FastButton(..)it fires the alert again :(I get this wrong behavior on iPhone 4S iOS 6 and iPad 3 with iOS 5.1.On android it seems to work.I get the same weird behavior with jquery.tappable.js.Thanks! 解决方案 I think the FastButton implementation already prevents the Ghostclick (timeout of a few milliseconds).I had the same problem, as I think the problem might be in the fact that you're using and alert (as I was). For some reason (I haven't dived deep into the code), you get another event fired because of the alert. If you're only trying the code out, use "console.log" which is non-blocking instead of alert, and you might see that this second event does not get called.Hopefully the idea is not to use the alert command, but if it is, use it with a timeout, which works around the implementation of ghostclick, which is what i think is breaking the behaviour anyway:new FastButton(document.getElementById('a'), function() { setTimeout('alert("hello");',500);});Hope it helps.Cheers, Miguel 这篇关于Google FastButton在iOS上点击两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 07:51