3

我在页面中有一个具有滚动条的 div,当 div 滚动结束时,页面滚动开始。这是任何浏览器的默认行为,但我仍然想在 div 滚动结束后停止滚动页面。我对此有一个修复,这是我在小提琴中创建的示例。

但上述解决方案适用于 Chrome、Firefox、IE9。但不能在 IE8 中工作。

如果您找到解决方案,请告诉我。

谢谢,戈皮

4

1 回答 1

0

正如 Andrew 上面所说,您是否尝试过 @amustill 的这个演示(防止父元素滚动?)?

演示:

http://jsbin.com/ixura3/3/

JS:

$(function() {

  var toolbox = $('#toolbox'),
      height = toolbox.height(),
      scrollHeight = toolbox.get(0).scrollHeight;

  toolbox.bind('mousewheel', function(e, d) {
    if((this.scrollTop === (scrollHeight - height) && d < 0) || (this.scrollTop === 0 && d > 0)) {
      e.preventDefault();
    }
  });

});

HTML:

<div id="toolbox">
    Text that scrolls...
</div>

这需要 jQuery 和jQuery Mousewheel 插件

于 2012-08-25T18:52:09.290 回答