最初の一歩:
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
2番目のステップ:
window.onload = function () {
document.addEventListener('gesturestart', function (e) {
e.preventDefault();
});
//以上是禁止双指缩放
//以下是禁止双击缩放
document.addEventListener('touchstart', function (e) {
if (e.touches.length > 1) {
e.preventDefault();
}
});
var endTouch = 0;
document.addEventListener('touchend', function (e) {
var nowTouch = (new Date()).getTime();
if (nowTouch - endTouch<= 300) { //为什么是300,看注意
e.preventDefault();
}
endTouch = nowTouch ;
}, false);
};
注:
クリックの浸透の問題:モバイル端末のクリックには、タッチスタート/タッチエンドよりも約300ミリ秒の遅延があります。ブラウザは、クリック後300ミリ秒待機して、ユーザーが複数回クリックするかどうかを判断します。300ミリ秒以内に複数のクリックがある場合は、クリックイベントではないと判断されました。