无论如何,有使用JavaScript检测OS语言的方法吗?

编程入门 行业动态 更新时间:2024-10-12 20:20:12
本文介绍了无论如何,有使用JavaScript检测OS语言的方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要使用javascript检测操作系统语言,以便可以根据语言查看我的页面.

I need to detect OS language using javascript so I can view my page depending on the language.

我知道我们可以检测到浏览器语言,但这对我来说还不够.

I know that we can detect the browser language but that is not enough for me.

我需要操作系统语言

预先感谢

推荐答案

没有跨浏览器的方法. Internet Explorer支持以下内容:

There is no cross-browser way to do this. Internet Explorer supports the following:

  • navigator.browserLanguage:浏览器语言
  • navigator.systemLanguage:Windows系统语言
  • navigator.userLanguage:Windows用户特定语言
  • navigator.browserLanguage: browser language
  • navigator.systemLanguage: Windows system language
  • navigator.userLanguage: Windows user-specific language

但是无法从其他任何浏览器访问这些设置(据我所知),所以不要使用它们:坚持使用标准navigator.language(与浏览器语言相对应)如果要维护跨浏览器功能.如果您确实使用它们,则会将您的网站绑定到特定的操作系统家族(例如Windows)和特定的浏览器(例如Internet Explorer).您真的要这样做吗?

But there is no way to access these settings from any other browsers (that I can tell) so don't use them: stick to the standard navigator.language (corresponding to the browser language) if you want to maintain cross-browser functionality. If you do use them you will tie your web site to a specific family of operating systems (i.e. Windows) and a specific browser (i.e. Internet Explorer). Do you really want to do this?

为什么浏览器语言不足以支持您的应用?

Why is the browser language insufficient for your application?

更多推荐

无论如何,有使用JavaScript检测OS语言的方法吗?

本文发布于:2023-10-08 14:59:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1472967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无论如何   语言   方法   OS   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!