Changing Scrollbar Position

前端 未结 4 846
借酒劲吻你
借酒劲吻你 2020-12-02 15:55

Is it possible to change the scrollbar position when the user reaches a certain point scrolling down a web page? For example once you reached half way down down the page the

4条回答
  •  爱一瞬间的悲伤
    2020-12-02 16:24

    The three scrolling functions you'll want to concern yourself with are window.scroll(x,y), window.scrollBy(dx,dy), and window.scrollTo(x,y).

    As David mentioned you'll need the scroll position to know where you are and use the window.onscroll event to fire off this calculation.

提交回复
热议问题