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 inWeb Workers.
Thelanguagechange event is fired at the global scope object when the user's preferred language changes.
This event is not cancelable and does not bubble.
In this article
Syntax
Use the event name in methods likeaddEventListener(), or set an event handler property.
js
addEventListener("languagechange", (event) => { })onlanguagechange = (event) => { }Event type
A genericEvent.
Examples
You can use thelanguagechange event in anaddEventListener method:
js
worker.addEventListener("languagechange", () => { console.log("languagechange event detected!");});Or use theonlanguagechange event handler property:
js
worker.onlanguagechange = (event) => { console.log("languagechange event detected!");};Specifications
| Specification |
|---|
| HTML> # event-languagechange> |
| HTML> # handler-workerglobalscope-onlanguagechange> |