禁止鼠标滑过滚动条滚动

document.body.onmousewheel = function () {return false;}

恢复鼠标滑过滚动条滚动

document.body.onmousewheel = function () {return true;}

禁止键盘控制滚动条滚动

document.body.onkeydown = function (e) {
  if (e.keyCode == 38 || e.keyCode == 40) {
     return false;
  }
}

恢复键盘控制滚动条滚动

document.body.onkeydown = function (e) {
  if (e.keyCode == 38 || e.keyCode == 40) {
     return true;
  }
}

css隐藏滚动条样式:

::-webkit-scrollbar {
   overflow-x:hidden;
}

 

posted on 2020-03-22 22:20  毛会懂  阅读(7432)  评论(0编辑  收藏  举报