HashChangeEvent: HashChangeEvent() constructor
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HashChangeEvent() constructor creates a new HashChangeEvent object, that is used by the hashchange event fired at the window object when the fragment of the URL changes.
Note:
A web developer doesn't typically need to call this constructor, as the browser creates these objects itself when firing hashchange events.
Syntax
new HashChangeEvent(type, options)
Parameters
type-
A string with the name of the event. It is case-sensitive and browsers set it to
hashchange. optionsOptional-
An object that, in addition to the properties defined in
Event(), has the following properties:oldURLOptional-
A string containing the old URL. Its default value is the empty string (
""). newURLOptional-
A string containing the new URL. Its default value is the empty string (
"").
Return value
A new HashChangeEvent object.
Specifications
| Specification |
|---|
| HTML> # the-hashchangeevent-interface> |
Browser compatibility
Loading…
See also
hashchangeevent