本文介绍了浏览器不使用utf-8,但设置了meta标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的页面标题:

 <!DOCTYPE html> 
< html>
< head>
< meta http-equiv =content-typecontent =text / html; charset = UTF-8>
...

正如您所看到的,charset设置为utf-8,但Chrome / Firefox不会将该页面打印为utf-8。我猜这是因为服务器发送这个头文件:

  Content-Type:text / html; charset = ISO-8859-15 

如何从我的html页面覆盖此标题?

解决方案

不能。

HTTP标题优先于元素声称是等同的。



修复您的服务器设置,以便发送正确的内容类型。


This is my page header:

<!DOCTYPE html> 
<html> 
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
...

As you can see the charset is set to utf-8 but Chrome/Firefox does not print the page as utf-8. I guess that is because the server sends this header:

Content-Type:text/html; charset=ISO-8859-15

How can I overwrite this header from my html page?

解决方案

You can't.

HTTP headers have priority over meta elements that claim to be equivalent.

Fix your server settings so it sends the correct content-type.

这篇关于浏览器不使用utf-8,但设置了meta标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 03:25