【问题标题】:The character encoding declaration of the HTML document was not found未找到 HTML 文档的字符编码声明
【发布时间】:2014-09-12 13:46:00
【问题描述】:

在我的 firefox 网页控制台中随机出现这个问题(是 js 选项卡)

它只是刚刚出现,无法链接到我所做的任何更改。

完整的错误是:

The page was reloaded, because the character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

或者这个:

The character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. When viewed in a differently-configured browser, this page will reload automatically. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.

问题指向这一行:

<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />

对我来说,那个元标记可以吗?任何我认为有冲突并导致其他事情出现问题的帮助。

克雷格

【问题讨论】:

    标签: javascript html utf-8 character-encoding meta


    【解决方案1】:

    我在 Firefox 中收到此错误消息。当我“pagespeed DisableFilters add_head;”在我的 nginx 设置中,它消失了。

    【讨论】:

      【解决方案2】:

      Charset 是 content-type 的参数,不是单独的属性:

      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
      

      或者,如果您想使用 HTML 5 样式:

      <meta charset="utf-8">
      

      您还应该注意错误消息:

      预扫描文件的前 1024 个字节时未找到

      您可能需要将元标记移到文档上方。理想情况下,它应该是&lt;head&gt; 中的第一个标签。

      【讨论】:

      • 我已将我的 init 文件(包含要包含在每个页面中的内容)移到元上方,我猜测这会将头部中的元推到范围之外。不过现在排序了,谢谢:)
      猜你喜欢
      • 2015-12-05
      • 2012-07-22
      • 1970-01-01
      • 2012-11-09
      • 2014-08-27
      相关资源
      最近更新 更多