Focus eventsBaseline · Widely available
Focus events, such as focus and blur, fire when an element gets or loses focus.
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+Supportedsince Dec 11, 2008
Current: 155Edge
12+Supportedsince Jul 29, 2015
Current: 154Firefox
1–23Not supported
24+Supportedsince Sep 17, 2013
Current: 157Safari
1–3Not supported
3.1+Supportedsince Mar 18, 2008
Current: 27MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155Firefox Android
4–23Not supported
24+Supportedsince Sep 17, 2013
Current: 157Safari iOS
1–1Not supported
2+Supportedsince Jul 11, 2008
Current: 27How to use
This feature is Baseline widely available — use it freely, no fallback needed.
Example
Full syntax and examples are on MDN: blur event.
Feature detection
JS · check before using
if ("FocusEvent" in globalThis) {
// FocusEvent is available
} else {
// load a polyfill or use a fallback
}Sub-features
Support for each part of the feature (11). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| Element.blur_event | 1 | 12 | 6 | 3.1 | 18 | 6 | 2 |
| Element.focus_event | 1 | 12 | 24 | 3.1 | 18 | 24 | 2 |
| Element.focusin_event | 1 | 12 | 52 | 5 | 18 | 52 | 4.2 |
| Element.focusout_event | 1 | 12 | 52 | 5 | 18 | 52 | 4.2 |
| FocusEvent | 26 | 12 | 24 | 7 | 26 | 24 | 7 |
| FocusEvent.FocusEvent | 26 | 12 | 24 | 7 | 26 | 24 | 7 |
| FocusEvent.relatedTarget | 26 | 12 | 24 | 7 | 26 | 24 | 7 |
| HTMLElement.blur | 1 | 12 | 1.5 | 3 | 18 | 4 | 1 |
| HTMLElement.focus | 1 | 12 | 1.5 | 3 | 18 | 4 | 1 |
| HTMLElement.focus.options_focusVisible_parameter | 145 | 145 | 104 | 18.4 | 145 | 104 | 18.4 |
| HTMLElement.focus.options_preventScroll_parameter | 64 | 17 | 68 | 15 | ✕ | ✕ | 15.5 |