files/en-us/web/api/hashchangeevent/index.md
{{APIRef("HTML DOM")}}
The HashChangeEvent interface represents events that fire when the fragment identifier of the URL has changed.
The fragment identifier is the part of the URL that follows (and includes) the # symbol.
{{InheritanceDiagram}}
HashChangeEvent object.This interface also inherits the properties of its parent, {{domxref("Event")}}.
This interface has no methods of its own, but inherits the methods of its parent, {{domxref("Event")}}.
function locationHashChanged() {
if (location.hash === "#some-cool-feature") {
someCoolFeature();
}
}
window.addEventListener("hashchange", locationHashChanged);
{{Specifications}}
{{Compat}}