移动端H5页面加上 <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"> 还是会被浏览器强制缩放。
使用下面的JS可以禁止此事件
document.documentElement.addEventListener( "touchstart", function(event) { if (event.touches.length > 1) { event.preventDefault(); } },
{ passive: false } ); // 禁止双击放大 let lastTouchEnd = 0; document.documentElement.addEventListener( "touchend", function(event) { var now = Date.now(); if (now - lastTouchEnd <= 300) { event.preventDefault(); } lastTouchEnd = now; },
{ passive: false } );
标签:禁止,浏览器,缩放,false,强制,now,event From: https://www.cnblogs.com/fubuki/p/17919300.html