coderef

hashchangeBaseline · Widely available

The hashchange event fires when the URL fragment identifier (the part of the URL starting with #) of the current page has changed.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1–15Not supported
16+Supportedsince Dec 13, 2011
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1–10Not supported
11+Supportedsince Mar 13, 2012
Current: 157
Safari
1–5.1Not supported
6+Supportedsince Jul 25, 2012
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4–10Not supported
14+Supportedsince Jun 26, 2012
Current: 157
Safari iOS
1–5Not supported
6+Supportedsince Sep 10, 2012
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: HashChangeEvent.

Feature detection

JS · check before using
if ("HashChangeEvent" in globalThis) {
  // HashChangeEvent is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (5). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
HashChangeEvent8123.651845
HashChangeEvent.HashChangeEvent161211618146
HashChangeEvent.newURL81265.11865
HashChangeEvent.oldURL81265.11865
Window.hashchange_event4123.651845