NavigatorLanguage

NavigatorLanguage 包含涉及导航(Navigator)的语言特性的方法和属性。

其实 NavigatorLanguage 这个对象并不存在,但是,一些其它的接口,如 NavigatorWorkerNavigator,实现了它。

属性

NavigatorLanguage 接口不继承任何属性。

NavigatorLanguage.language 只读
返回一个 DOMString 代表用户的首选语言,通常是浏览器 UI 的语言。若返回 null 值,则代表语言未知。
NavigatorLanguage.languages 只读
返回一个 DOMString 数组,代表用户已知的语言,不同语言按照谁更佳排序。

方法

NavigatorLanguage 接口不依赖任何接口和方法。

标准

标准 状态 备注
HTML Living Standard
NavigatorLanguage
Living Standard HTML5 出现开始,languages 属性已经被添加。
HTML5
NavigatorLanguage
Recommendation 初始标准;出现在 HTML Living Standard 的早期版本。

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
NavigatorLanguageChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 11Opera Full support 4Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0
languageChrome Full support 1
Notes
Full support 1
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Edge Full support 12
Notes
Full support 12
Notes
Notes In Chromium versions of Edge, this returns the browser UI language, not the value of the Accept-Language HTTP header.
Firefox Full support 1
Notes
Full support 1
Notes
Notes Prior to Firefox 4, this property's value was also part of the user agent string, as reported by navigator.userAgent. Starting in Firefox 5, this property's value is based on the value of the Accept-Language HTTP header.
IE Full support 11
Notes
Full support 11
Notes
Notes Closest available (non-standard) properties are userLanguage and browserLanguage.
Opera Full support 4Safari Full support 1WebView Android Full support 1
Notes
Full support 1
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Chrome Android Full support 18
Notes
Full support 18
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0
Notes
Full support 1.0
Notes
Notes Returns the browser UI language, not the value of the Accept-Language HTTP header.
languages
Experimental
Chrome Full support 32
Notes
Full support 32
Notes
Notes In Chrome, navigator.language is the language of the browser UI, and is not guaranteed to be equal to navigator.languages[0].
Edge Full support 12
Notes
Full support 12
Notes
Notes In Chromium versions of Edge, this returns the browser UI language, not the value of the Accept-Language HTTP header.
Firefox Full support 32
Notes
Full support 32
Notes
Notes In Firefox, the navigator.languages property's value is taken from the intl.accept_languages preference.
IE Full support 11
Notes
Full support 11
Notes
Notes Closest available (non-standard) properties are userLanguage and browserLanguage.
Opera Full support 24Safari Full support 11WebView Android Full support 4.4.3
Notes
Full support 4.4.3
Notes
Notes In Chrome, navigator.language is the language of the browser UI, and is not guaranteed to be equal to navigator.languages[0].
Chrome Android Full support 32
Notes
Full support 32
Notes
Notes In Chrome, navigator.language is the language of the browser UI, and is not guaranteed to be equal to navigator.languages[0].
Firefox Android Full support 4
Notes
Full support 4
Notes
Notes In Firefox, the navigator.languages property's value is taken from the intl.accept_languages preference.
Opera Android Full support 24Safari iOS Full support YesSamsung Internet Android Full support 2.0
Notes
Full support 2.0
Notes
Notes In Samsung Internet, navigator.language is the language of the browser UI, and is not guaranteed to be equal to navigator.languages[0].
Available in workersChrome ? Edge ? Firefox Full support 35IE No support NoOpera ? Safari No support NoWebView Android ? Chrome Android ? Firefox Android Full support 35Opera Android ? Safari iOS No support NoSamsung Internet Android ?

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 implementation notes.
See implementation notes.

参见