移动端禁止页面拖动 h5禁止拖动页面


 

PC上css控制滚动仅css("overflow","hidden")已足够。

但是,如果在Mobile上还是可以拖动的!所以需要监听touchmove事件。

 

页面禁止拖动、滚动:

$("html,body").css("overflow","hidden").css("height","100%");
                        document.body.addEventListener('touchmove', self.welcomeShowedListener, false);

 

恢复页面拖动、滚动:

$("html,body").css("overflow","").css("height","");
                    document.body.removeEventListener('touchmove', detail.welcomeShowedListener, false);

 

参考:

在移动端设置overflow:hidden为什么页面还能滚?要怎么禁止

移动端的touch事件处理

addEventListener()与removeEventListener() 用法详解

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM