how to change url without changing browser history

浪尽此生 提交于 2019-12-02 21:40:46
adeneo

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!