how to change url without changing browser history

后端 未结 1 1508
清酒与你
清酒与你 2021-02-02 05:29

Until now, I only know that if I want to change URL without reloading the whole page i have to use HTML browser history API.

I am using this concept in my website. Let\'

相关标签:
1条回答
  • 2021-02-02 06:26

    You're looking for replaceState(), it replaces the current position in the history instead of pushing a new one, like pushState() does

    from MDN

    history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one.

    replaceState() is particularly useful when you want to update the state object or URL of the current history entry in response to some user action.

    Remember, some functions are not available on older browsers. But there is a library that could help you out.

    0 讨论(0)
提交回复
热议问题