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.
io error: No such file or directory (os error 2) (/home/runner/work/yari/yari/mdn/translated-content/files/zh-tw/web/api/html_dom_api/index.md)
Navigator.language
是一個唯讀的屬性,回傳使用者偏好的語言字串,通常是瀏覽器 UI 的文字
語法
js
const lang = navigator.language
值
範例
js
if (/^en\b/.test(navigator.language)) {
doLangSelect(window.navigator.language);
}
規格
Specification |
---|
HTML Standard # dom-navigator-language-dev |
瀏覽器相容性
BCD tables only load in the browser