WorkerGlobalScope: languagechange event

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

This event is not cancelable and does not bubble.

Syntax

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

addEventListener('languagechange', (event) => { });

onlanguagechange = (event) => { };

Event type

A generic Event.

Examples

You can use the languagechange event in an addEventListener method:

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

Or use the onlanguagechange event handler property:

worker.onlanguagechange = (event) => {
  console.log('languagechange event detected!');
};

Specifications

Specification
HTML Standard
# event-languagechange
HTML Standard
# handler-workerglobalscope-onlanguagechange

Browser compatibility

BCD tables only load in the browser

See also