Change url when manually scrolled to an anchor?

后端 未结 6 1758
失恋的感觉
失恋的感觉 2020-11-30 01:53

By Default, if I have anchors in my website, then the URL on the address bar is changed, when I click on a link (ie. www.mysite.com/#anchor)

Is it possible to change

6条回答
  •  孤城傲影
    2020-11-30 02:47

    1. Bind a handler to jquery scroll event.
    2. Check if an anchor is currently visible on-screen with this jquery script.
    3. Use pushstate or set location (probably will cause jumps)

提交回复
热议问题