scroll - 如果单击调查下一个按钮,我如何禁用滚动
问题描述
知道为什么每次单击其中一个答案时,整个屏幕都会突然移动到顶部吗?
调查链接:https ://app.grillomarketing.com/v2/preview/Gg3ERkkv4fCAUmGor5pL
解决方案
function disableScroll() {
scrollTop = window.pageYOffset || document.documentElement.scrollTop;
scrollLeft = window.pageXOffset || document.documentElement.scrollLeft,
// if any scroll is attempted, set this to the previous value
window.onscroll = function() {
window.scrollTo(scrollLeft, scrollTop);
};
}
function enableScroll() {
window.onscroll = function() {};
}
This code will disable scroll fully but you might have some event listener that scrolls to the element when button is clicked.
推荐阅读
- javascript - 如何在node.js中的.then链中传递promise数据?
- rust - Rust:我在哪里可以找到 crate 中示例的必要依赖项(这里是 espc. druid)?
- c - 在第二个函数内释放 C 中动态分配的数组
- javascript - Javascript 和 HTML 中的数字警报
- javascript - 如何设置部分字符串粗体?
- python-3.x - AttributeError: 'Linkedlist' 对象没有属性 'printLinkedlist' ==> 链表
- linux - Bash 脚本 udev 播放声音
- python - 数据框 - 根据来自另一个数据框的输入插入值
- sharepoint - 如何使用 JSOM 在根站点集合的属性包中设置属性?
- php - 通过 URL 使用 php 重定向到其他页面