W3cubDocs

/Web APIs

Window: languagechange event

The languagechange event is fired at the global scope object when the user's preferred language changes.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js

addEventListener("languagechange", (event) => {});
onlanguagechange = (event) => {};

Event type

A generic Event.

Event handler aliases

In addition to the Window interface, the event handler property onlanguagechange is also available on the following targets:

Examples

You can use the languagechange event in an addEventListener method:

js

window.addEventListener("languagechange", () => {
  console.log("languagechange event detected!");
});

Or use the onlanguagechange event handler property:

js

window.onlanguagechange = (event) => {
  console.log("languagechange event detected!");
};

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
languagechange_event 37 79 32 No 24 10.1 37 37 4 24 10.3 4.0

See also

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/languagechange_event