Html 在Firefox中错误显示UTF-8编码文本
以下文档保存为不带bom的UTF-8:Html 在Firefox中错误显示UTF-8编码文本,html,firefox,character-encoding,meta-tags,Html,Firefox,Character Encoding,Meta Tags,以下文档保存为不带bom的UTF-8: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>AB - Adasdajhasbkfjqnefibqfn </title> <l
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>AB - Adasdajhasbkfjqnefibqfn </title>
<link rel="shortcut icon" href="http://www.my-domain.net/bilder/favicon.ico" >
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA*******-1', 'my-domain.net');
ga('send', 'pageview');
</script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta http-equiv="Content-Style-Type" content="text/css">
<link href="http://www.does-not-exists.net/style2.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>äöü</p>
</body>
</html>
AB-Adasdajhasbkfjqnefibqfn
(函数(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]| |函数(){
(i[r].q=i[r].q | |[]).push(参数)},i[r].l=1*新日期();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(窗口,文档,“脚本”,“www.google-analytics.com/analytics.js”,“ga”);
ga('create','UA*********-1','mydomain.net');
ga(‘发送’、‘页面浏览’);
äöü
如果我加载此页面,则会正确看到:äöü
当我通过如下表单从另一个页面加载页面时:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form name='mainForm' action='step2t.php' enctype=\"multipart/form-data\" method='post'>
<input type='submit' >
</form>
</body>
</html>
然后,我在Chrome中看到了äöü,甚至在IE 8中也看到了äöü,但在Firefox中我看到了
Ã
现在,如果我删除以下任何一行:
<title>AB - Adasdajhasbkfjqnefibqfn </title>
AB-Adasdajhasbkfjqnefibqfn
(函数(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]| |函数(){
(i[r].q=i[r].q | |[]).push(参数)},i[r].l=1*新日期();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(窗口,文档,“脚本”,“www.google-analytics.com/analytics.js”,“ga”);
ga('create','UA*********-1','mydomain.net');
ga(‘发送’、‘页面浏览’);
然后它突然在Firefox中运行起来
有任何关于此文档在Firefox中无法正常工作的线索吗?标签应该是打开
标签后的第一个标签,因为它告诉浏览器文档其余部分使用的是什么字符集(浏览器会猜到此点之前的字符集)
资料来源:(见附注部分)
请注意,将其作为第一个标记不是强制性的(它可以出现在前512字节内的任何位置),但这样做是一个很好的经验法则,可以避免在所有html文档中计算512字节。标记应该是打开
标记后的第一个标记,因为它告诉浏览器文档的其余部分使用什么字符集(浏览器会在这一点之前猜测字符集)
资料来源:(见附注部分)
请注意,将其作为第一个标记不是强制性的(它可以出现在前512字节内的任何位置),但这样做是一个很好的经验法则,可以避免在所有html文档中计算512字节的数量。你的
你的Firefox版本是什么?@tcooc OMG-它起作用了。我把最后三个小时花在那个问题上。你能把这个作为答案发出来吗?我可以检查一下吗?@curiosu its Version 31.0Your你的Firefox版本是什么?@tcooc OMG-它成功了。我把最后三个小时花在那个问题上。你能把它作为一个答案发布吗?@curiosu它的31.0版不需要是第一个,但它需要在数据流中“足够早”出现,否则浏览器可能会在看到标签之前猜测编码。@JukkaK.Korpela True,但这是一个很好的经验法则。计算每个html文件要检查的512字节是相当繁琐的。编辑问题来指出这一点。将来,每当我的html文档出现问题时,我会首先检查这个问题:D。非常感谢!它不需要是第一个,但需要在数据流中“足够早”出现,否则浏览器可能会在看到标记之前猜测编码。@JukkaK.Korpela True,但这是一个很好的经验法则。计算每个html文件要检查的512字节是相当繁琐的。编辑问题来指出这一点。将来,每当我的html文档出现问题时,我会首先检查这个问题:D。非常感谢!
<link rel="shortcut icon" href="http://www.my-domain.net/bilder/favicon.ico" >
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA*******-1', 'my-domain.net');
ga('send', 'pageview');
</script>
<meta http-equiv="Content-Style-Type" content="text/css">
<link href="http://www.does-not-exists.net/style2.css" rel="stylesheet" type="text/css" />