js禁止页面滚动:

如果想要禁止整个页面滚动:

document.body.addEventListener('touchmove', function(e){
     e.preventDefault();
 }, { passive: false });  //passive 参数不能省略,用来兼容ios和android

如果想要禁止弹框滚动:

var modal=document.getElementById("modal");
modal.addEventListener('touchmove', function(e){
    e.preventDefault();
}, { passive: false });  //passive 参数不能省略,用来兼容ios和android

 

posted @ 2020-09-23 10:55  猛猛滴超人  阅读(949)  评论(0)    收藏  举报