WorkerGlobalScope: languagechange event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Note: This feature is only available in Web Workers.
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 addEventListener():
js
addEventListener("languagechange", (event) => { })
Alternatively, assign to the event handler property of the interface:
js
onlanguagechange = (event) => { }
Event type
A generic Event.
Examples
You can use the languagechange event in an addEventListener method:
js
self.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):
js
self.onlanguagechange = (event) => {
console.log("languagechange event detected!");
};
Specifications
| Specification |
|---|
| HTML> # event-languagechange> |
| HTML> # handler-workerglobalscope-onlanguagechange> |