Scrolling within a div without moving page

后端 未结 5 1510
忘了有多久
忘了有多久 2020-12-19 19:46

I have a

with overflow-y:scroll;. Links to anchors within innerContent are located on parent page, not in the
5条回答
  •  遥遥无期
    2020-12-19 20:34

    And if you do decide to use javascript (again, like KooiInc said, if you don't need js, don't use it), you can try using event.cancelBubble = true, which would prevent the event from propagating to the parent container so the page would not see your inner-div scrolling. Additional command you can use is event.preventDefault(), which prevents browser from triggering default behavior (i.e. scrolling) to the event.

提交回复
热议问题