【发布时间】:2017-01-25 11:10:04
【问题描述】:
我知道这可能看起来像重复,但我查看了网站上以前的答案,但在尝试实施不同的解决方案时没有成功。
所以,就这样吧。
我创建了一个页面,由于敏感信息,我必须在其中提供模态/免责声明。 我已经设法在桌面和移动设备上禁用背景正文滚动。在桌面上,我还设法在单击模式中的按钮后重新启用滚动。但是,在移动设备上,当用户单击模式中的按钮后,滚动保持禁用状态。
这是我的 JS:
<script>
window.onload = function () {
$('body').css('overflow','hidden')
document.body.addEventListener("touchmove", function(event) {
event.preventDefault();
}, false);
document.getElementById('button').onclick = function () {
$('body').css('overflow','scroll')
document.body.addEventListener("touchmove", function(event) {
event.preventDefault();
}, true);
document.getElementById('modal').style.display = "none"
};
};
</script>
如您所见,我尝试在单击按钮时在同一事件侦听器的末尾添加“true”。这不起作用:(
非常感谢任何帮助!
【问题讨论】:
标签: javascript jquery html css jquery-mobile