h5 页面 禁止网页缩放

//禁用双指缩放:

document.documentElement.addEventListener('touchstart', function (event) {
  if (event.touches.length > 1) {
    event.preventDefault();
  }
}, false);

//禁用手指双击缩放:

var lastTouchEnd = 0;
document.documentElement.addEventListener('touchend', function (event) {
  var now = Date.now();
  if (now - lastTouchEnd <= 300) {
    event.preventDefault();
  }
  lastTouchEnd = now;
}, false);
posted @ 2018-08-16 17:16  geek程序员  阅读(...)  评论(... 编辑 收藏