您的位置:首页 > 移动开发

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

2016-07-07 14:10 696 查看
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() 用法详解
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: