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)  
    }

  

posted @ 2019-07-17 09:16  后知_后觉  阅读(2072)  评论(0编辑  收藏  举报