跳转到主要内容

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 addEventListener():

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

Alternatively, assign to the event handler property of the interface:

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:

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

Or use the onlanguagechange event handler property (but note that this replaces other event listeners added using onlanguagechange, if any):

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

Specifications

Browser compatibility

See also