window.history.pushstate
时间: 2023-10-31 16:45:46 浏览: 43
window.history.pushState is a method of the JavaScript History API that allows you to add a new state to the browser history without actually reloading the page. This method is used to manipulate the browser's history and change the URL displayed in the address bar of the browser.
The pushState() method takes three parameters:
- state object: an object that represents the state you want to push to the browser's history. This state object can be used later to restore the state of the page when the user clicks the back or forward button.
- title: the title of the new state.
- URL: the URL of the new state.
When pushState() is called, it adds a new entry to the browser history, which allows the user to navigate back and forth between the different states of the web page. This method is commonly used in single-page applications to update the URL displayed in the address bar without actually refreshing the page, making the app feel more like a traditional multi-page website.