HTML DOM
The HashChangeEvent() constructor creates a new HashChangeEvent object, that is used by the Window/hashchange_event 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 Window/hashchange_event 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.
- : A string with the name of the event.
It is case-sensitive and browsers set it to
options- : An object that, in addition to the properties defined in Event/Event, has the following properties:
oldURL- : A string containing the old URL. Its default value is the empty string (
"").
- : A string containing the old URL. Its default value is the empty string (
newURL- : A string containing the new URL. Its default value is the empty string (
"").
- : A string containing the new URL. Its default value is the empty string (
- : An object that, in addition to the properties defined in Event/Event, has the following properties:
Return value
A new HashChangeEvent object.
Specifications
Browser compatibility
See also
- Window/hashchange_event event
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
