Favorites

HTML onlanguagechange Event Attribute

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
onlanguagechange
HTML Event AttributeThis event attribute is supported by all modern browsers.
Updated 22nd November 2026

Description

The onlanguagechange event attribute is used on the <body> element (or as window.onlanguagechange) and runs a script when the user's preferred languages change, that is, when the value of navigator.language and navigator.languages changes, usually because the user changed the browser's language settings.

It lets a page update its translated text, or dates and numbers formatted with Intl, without reloading. The event is also available in web workers.

Syntax

<body onlanguagechange="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html>
<html>
<head>
<title>onlanguagechange event</title>
</head>
<body>
<p>Your preferred language: <strong id="lang"></strong></p>
<p>Change the language settings of your browser to see the event fire.</p>
<script>
function show() {
document.getElementById("lang").textContent = navigator.languages.join(", ");
}
show();
window.onlanguagechange = show;
</script>
</body>
</html>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML onlanguagechange event attribute. Hover over a browser icon to see the version that first introduced support for this HTML event attribute.

This event attribute is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee