ios下设置user-scalable=no无效

在ios中屏蔽了meta中user-scalable=no的功能,如果想要实现禁止缩放功能需要通过js去实现

//通过touchstart和touchend
window.onload=function () {  
        document.addEventListener('touchstart',function (event) {  
            if(event.touches.length>1){  
                event.preventDefault();  //阻止元素的默认行为
            }  
        })  
        var lastTouchEnd=0;  
        document.addEventListener('touchend',function (event) {  
            var now=(new Date()).getTime();  
            if(now-lastTouchEnd<=300){  
                event.preventDefault();  
            }  
            lastTouchEnd=now;  //当前为最后一次触摸
        },false)  
    }

  

原文地址:https://www.cnblogs.com/m-yk/p/11198842.html