javascript - 显示不同的语言文本
问题描述
I'm new to HTML, and I want to display a message when JavaScript is disabled. So I put the message inside <noscript>
tag, which works fine.
<noscript> Need to enable Javascript. </noscript>
But I want to change this language to Chinese when the browser language is Chinese. I can't use JavaScript because this message only displays when JavaScript is disabled. Is there any way to solve this? Thank you!
解决方案
当浏览器使用 PHP 发出 HTTP 请求时,它会发送标头。
因此,您可以尝试使用:
_SERVER["HTTP_ACCEPT_LANGUAGE"]
或者
_SERVER["HTTP_ACCEPT_CHARSET"]
推荐阅读
- cassandra - Cassandra 在连接 Sails.js 时抛出错误
- java - 错误:找不到符号方法 setLatestEventInfo(Context,CharSequence,CharSequence,PendingIntent)
- apache-camel - 在骆驼 2.22.x 中,我如何强制 SEDA 具有无限的队列大小?
- algorithm - 如何以最短的方式连接所有连接的组件
- jenkins-pipeline - 当管道名称以交付结尾时,如何跳过 Jenkinsfile 管道中的一个阶段?
- html - 复选框“输入”的纯 CSS 样式作为翻转开关,并保留其现有的“标签”
- visual-studio-code - 用不同的浏览器打开 Angular 项目?
- php - 我正在对数据库中的数据进行排序,但网页没有生效
- c# - 使用将调用 Windows 服务的控制台应用程序更新 WPF 应用程序
- prolog - 如何理解 Prolog 中的递归搜索?