Web APIs

History.replaceState()

Try the free JavaScript compiler

Replaces the current history entry state; the optional URL must satisfy document rewrite restrictions.

Formal Syntax & Structure

javascript syntaxjavascript
history.replaceState(state, unused, url?)

Parameters & Attributes

NameTypeDescription
stateanySerializable state.
unusedstringLegacy argument, normally empty.
urlstring | nullOptional rewritten URL.

Return Value

undefined

No return value.

Working Example

Example Snippetjavascript
(async () => {history.replaceState({page:2},"");console.log(history.state.page);})()
JavaScript Reference