Disable scrolling in all mobile devices

后端 未结 13 1075
粉色の甜心
粉色の甜心 2020-11-28 03:18

This sounds like there should be a solution for it all over the internet, but I am not sure why I cannot find it. I want to disable Horizontal scrolling on mobile devices. B

相关标签:
13条回答
  • 2020-11-28 04:22

    This works for me:

    window.addEventListener("touchstart", function(event){
                 if(event.target.tagName=="HTML" || event.target.tagName=="BODY"){
                         event.preventDefault();
                 }
    } ,false);
    

    It does not work 100% and I also added this:

    window.addEventListener("scroll",function(){
        window.scrollTo(0,0)
    },false)
    
    0 讨论(0)
提交回复
热议问题