在Android Web浏览器上停止300ms onclick延迟 [英] Stop 300ms onclick delay on Android web browser
问题描述
我有一个页面,当按下按钮时,会使用javascript这样的页面来播放mp3文件:
I have a page that plays an mp3 file when button pressed, using javascript like:
onclick="playAudio"
明显有300ms的延迟.我只想通过Nexus 5使用html5浏览器.因此,我不需要IE6等的任何备用代码.我所见过的每个解决方案似乎都非常复杂,无法使其正常工作.
There is the obvious 300ms delay. I want to use this through html5 browsers only, using the nexus 7 only. So I dont want any backup code for IE6 etc. Every solution I've seen seems quite complicated and I can't get it to work.
没有简单的javascript解决方案吗?
Is there no simple javascript solution?
推荐答案
在github上检查Fastclick项目.如果我理解您的问题,您只想摆脱触摸设备上的300毫秒延迟.该项目是一个polyfill,可以使触摸ui更加快速和响应.这是网址:
Check out the Fastclick project on github. If I understand your question, you just want to get rid of the 300ms delay on touch devices. This project is a polyfill to make touch uis much more snappy and responsive. Here is the url:
https://github.com/ftlabs/fastclick
用例:
只需像这样包含fastclick库:
Just include the fastclick library like so:
<script type='application/javascript' src='/path/to/fastclick.js'></script>
然后通过将以下内容放入您的主应用js文件中来实例化它:
And then just instantiate it by putting following in your main app js file:
window.addEventListener('load', function() {
new FastClick(document.body);
}, false);
希望有帮助!
这篇关于在Android Web浏览器上停止300ms onclick延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!