Navigator.language
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Navigator.language
是一個唯讀的屬性,回傳使用者偏好的語言字串,通常是瀏覽器 UI 的文字
語法
js
const lang = navigator.language
值
範例
js
if (/^en\b/.test(navigator.language)) {
doLangSelect(window.navigator.language);
}
規格
Specification |
---|
HTML # dom-navigator-language-dev |
瀏覽器相容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
language |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
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.