私はphonegapを使用していて、クリック応答を高速化するために「touchstart」を使用する必要がありました.
組み込みブラウザ (7 インチの Android 4.0.3 タブレット) で単純なページをテストしたところ、失敗したことがわかりました。
私はまだ同じ2つのタブレットでテストしました。次のページでは、button2 には「html_click」のみが表示され、button3 には「click」のみが表示されます。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf8">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width">
<title>Droid touch event test.</title>
</head>
<body>
<button id="button">touch it</button>
<button id="button2" ontouchstart="d_('html_touchstart')" onclick="d_('html_click')">html</button>
<button id="button3">touch 3</button>
<div id="db"></div>
<script>
function $(d){return document.getElementById(d)}
function d_(m){dbo.innerHTML=dbo.innerHTML+' '+m}
function ts1(e){d_('document touched')}
function ts2(e){d_('button touched')}
function eh(e){
d_(e.type);
}
var ets='touchstart',dbo=$('db');
document.addEventListener(ets,ts1,false);
$('button').addEventListener(ets,ts2,false);
$('button3').addEventListener(ets,eh,false);
$('button3').addEventListener('touchend',eh,false);
$('button3').addEventListener('click',eh,false);
</script>
</body>
</html>
touchstart が起動しないのはなぜですか? タッチイベントを機能させるために何かする必要がありますか? または、クリック応答を速くする他の方法はありますか?
イベントを使用mousedown
しましたが、機能しましたが、特に高速ではありませんでした。
(new Date()).getTime()
との差 (一部のinnerHTML
変更を含む)は 15 程度です。mousedown
click