This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The onlanguagechange
property of the WindowEventHandlers
mixin is the EventHandler
for processing languagechange
events.
These events are received by the object implementing this interface, usually a Window
, an HTMLBodyElement
, or an HTMLIFrameElement
. Such an event is sent by the browser to inform that the preferred languages list has been updated. The list is accessible via NavigatorLanguage.languages
.
Syntax
object.onlanguagechange = function;
Value
function
is the name of a user-defined function, without the()
suffix or any parameters, or an anonymous function declaration, such asfunction(event) {...}
. An event handler always has one single parameter, containing the event, here of typeEvent
.
Example
window.onlanguagechange = function(event) { console.log('languagechange event detected!'); };
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'WindowEventHandler.onlanguagechange' in that specification. |
Living Standard | Initial specification. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
onlanguagechange | Chrome Full support 37 | Edge Full support ≤79 | Firefox Full support 32 | IE No support No | Opera Full support 24 | Safari ? | WebView Android Full support 37 | Chrome Android Full support 37 | Firefox Android Full support 4 | Opera Android Full support 24 | Safari iOS ? | Samsung Internet Android Full support 4.0 |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
See also
- The
languagechange
event and its type,Event