由于 webkit 浏览器处理触摸事件,我尝试了几种不同的方法来消除 300 毫秒的延迟。库 FastClick.js 似乎是首选方法,但我在实现它时遇到了一些麻烦。我已经包含它并添加了一个事件侦听器,但我不知道我是否正确添加了侦听器。这应该有效还是我没有做某事?谢谢!
考虑下面的代码,其中
<!DOCTYPE html>
<html>
<head>
<title>
Calculator
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum- scale=1.0, user-scalable=no;">
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="phonegap.js">
</script>
<<script type='application/javascript' src='js/fastclick.js'></script>
<script type="text/javascript">
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
$(function() {
FastClick.attach(document.body);
});
}
function onDeviceReady()
{
}
</script>
<script>
window.addEventListener('load', function() {
new FastClick(document.body);
}, false);
</script>
<link rel="stylesheet" href="./css/jquerymobile.css" type="text/css">
<link rel="stylesheet" href="./css/jquerymobile.nativedroid.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body onload="onBodyLoad()">
<!--START OF PAGE 1-->
<div data-role="page" data-theme='b' id="one">
<div data-role="content">
<a href="#one" data-transition="none" data-
</div>
</div>
</body>