title | slug | page-type | browser-compat |
---|---|---|---|
PopStateEvent() |
Web/API/PopStateEvent/PopStateEvent |
web-api-constructor |
api.PopStateEvent.PopStateEvent |
{{APIRef("History API")}}
The PopStateEvent()
constructor creates a new {{domxref("PopStateEvent")}} object.
Note: A web developer doesn't typically need to call this constructor, as the browser creates these objects itself when firing {{domxref("Window/popstate_event", "popstate")}} events.
new PopStateEvent(type, options)
type
- : A string with the name of the event.
It is case-sensitive and browsers set it to
popstate
.
- : A string with the name of the event.
It is case-sensitive and browsers set it to
options
{{optional_inline}}- : An object that, in addition to the properties defined in {{domxref("Event/Event", "Event()")}}, has the following property:
state
{{optional_inline}}- : An object representing the state. Practically it is a value provided by the call to {{domxref("history.pushState()")}} or {{domxref("history.replaceState()")}}. If not set, it defaults to
null
.
- : An object representing the state. Practically it is a value provided by the call to {{domxref("history.pushState()")}} or {{domxref("history.replaceState()")}}. If not set, it defaults to
- : An object that, in addition to the properties defined in {{domxref("Event/Event", "Event()")}}, has the following property:
A new {{domxref("PopStateEvent")}} object.
{{Specifications}}
{{Compat}}
- {{domxref("history.pushState()")}}
- {{domxref("history.replaceState()")}}
- {{domxref("Window/popstate_event", "popstate")}} event