Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 得到一个;“未声明的字符编码”;Firefox中的错误_Javascript_Html_Firefox_Character Encoding - Fatal编程技术网

Javascript 得到一个;“未声明的字符编码”;Firefox中的错误

Javascript 得到一个;“未声明的字符编码”;Firefox中的错误,javascript,html,firefox,character-encoding,Javascript,Html,Firefox,Character Encoding,我正在研究,注意到我在chrome和firefox中得到了不同的结果。这是代码 <!doctype html> <html> <head> <title>SPA Chapter 1 section 1.2.2</title> <style type="text/css"></style> <script type="text/javascript"> var prison = fu

我正在研究,注意到我在chrome和firefox中得到了不同的结果。这是代码

<!doctype html>
<html>
<head>
  <title>SPA Chapter 1 section 1.2.2</title>
  <style type="text/css"></style>
  <script type="text/javascript">
    var prison = function () {
      console.log('made it to prison');
    };
    prison();
  </script>
</head>
<body>
  <div id="spa"></div>
</body>
</html>

有什么好处?FF webdev控制台中是否缺少设置?

当您在开发工具中启用控制台日志时,Firefox会在控制台日志中显示预期结果。它还显示一条消息,在某些版本中分类为错误消息,但不影响功能。它实际上是一条信息性消息,表示页面的字符编码没有以任何方式声明;看

控制控制台日志中显示内容的方式取决于您使用的开发工具。在当前版本的Firefox中使用名为Aurora的,您可以使用Ctrl-Shift K调用的,确保启用了“日志记录”(显示为黑色,而不是灰色),如下图所示:


您需要决定字符编码。对于任何现代应用,很少需要考虑任何其他选项比UTF-8。您可以通过在文本编辑器中将HTML文件保存为“UTF-8 with BOM”和/或使用
标题中的标记
来声明它。如果您仅使用后者,并且页面曾经通过HTTP发送,则应确保服务器不会在
内容类型
HTTP标头中发送冲突信息。

尝试添加标记
。我认为这与
控制台.log没有任何关系。你确定在重新加载页面时控制台已经打开了吗?你是如何为页面提供服务的?页面是否正常显示(可能会添加一些内容)?@pstenstrm可以利用endcoding错误,但我仍然无法在FF中显示控制台…在chrome中仍然可以正常工作。您提到的“所有”标记在哪里?@Lumbee,这有点令人困惑,因为人们使用不同的开发工具。我改变了答案,用了一个更通用的措辞,并用一个现代的例子来说明这一点。做到了。日志记录被关闭了…不知道这是怎么发生的。塔克斯!
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.