Web APIs
History.pushState()
Adds a session-history entry without a document load. Does not itself dispatch popstate.
Formal Syntax & Structure
javascript syntaxjavascript
history.pushState(state, unused, url?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| state | any | Serializable state. |
| unused | string | Legacy argument, normally empty. |
| url | string | null | Optional rewritten URL. |
Return Value
undefined
No return value.
Working Example
Example Snippetjavascript
(async () => {let calls=0;window.addEventListener("popstate",()=>calls++);history.pushState({page:3},"");console.log(history.state.page,calls);})()