经常遇到页面显示文字乱码问题,大多数是由于字符编码问题导致。
通常设置
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
在页面<head>头指定字符charset=utf-8等编码方式。
Always declare the encoding of your document. Use the HTTP header if you can. Always use an in-document declaration too.
Setting the character encoding should be done in the Content-Type http header, but can also be set with the <meta charset> attribute.
The charset specified in the meta element and http header must match.
查看了大多主流网站首页都将<meta http-equiv="Content-Type" content="text/html; charset=utf-8">放在<meta>标签下第一行,是为了在html页面在解析过程中先指定文档编码方式,防止浏览器自动检测使用何种方式,加快页面查找时间。
In order for all browsers to recognize a <meta charset> declaration, it must be
* Within the <head> element,
* Before any elements that contain text, such as the <title> element, AND
* Within the first 512 bytes of your document, including DOCTYPE and whitespace
百度:
<head>
<meta content="text/html;charset=gb2312" http-equiv="Content-Type">
<title>百度一下,你就知道</title>
</head>
QQ:
<head>
<meta content="text/html;charset=gb2312" http-equiv="Content-Type">
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
<title>腾讯首页</title>...
</head>
Yahoo
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Yahoo!</title>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
</head>
Taobao
<head>
<meta charset="gbk">
<title>淘宝网 - 淘!我喜欢</title>
</head>
参考:
http://code.google.com/intl/zh-CN/speed/page-speed/docs/rendering.html#SpecifyCharsetEarly
http://www.cnblogs.com/EWall/archive/2011/04/28/2031744.html
http://www.w3.org/International/tutorials/tutorial-char-enc/
http://code.google.com/p/doctype/wiki/MetaCharsetAttribute
http://htmlpurifier.org/docs/enduser-utf8.html
http://www.cherny.com/webdev/103/the-ie-8-x-ua-compatible-meta-tag
分享到:
相关推荐
html页面一般都会指定一个编码,如何获取到是处理html页面的第一步,因为错误的编码必然带来后面处理的问题。这里我用python的正则表达式写了个: import re a = ["<meta ...
1.html指定页面字符集的两种方式 方式一: <meta charset=utf-8> 方式二: <meta http-equiv=Content-Type content=text/html; charset=UTF-8>... 以上就是将页面的字符集设置...第二种:页面指定字符
然后用它将各个数据段分开,而对于每个数据段都对应着 HTML 页面表单中的一个 Input 区,包括一个 content-disposition 属性,说明了这个数据段的一些信息,如果这个数据段的内容是一个文件,还会有 Content-Type ...
实例如下: <!DOCTYPE html PUBLIC "-//...meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js print打印网页指定区域内容的简单实例</title> </head> <sc
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>title 解决方法是要在jsp最前面加上一条java语句,设置请求的字符编码。 request.setCharacterEncoding("gb2312"); %>
http-tester 一个微型Web服务,它从参数中的指定代码返回http错误页面。... 要启动服务器,请使用rackup -p 5000或将提供的Procfile与foreman start 。用法$ curl ... mode=blockX-Content-Type-
<meta http-equiv="X-UA-Compatible" content="IE=Edge">浏览器兼容 leftmargin="0" topmargin="0" marginheight="0" marginwidth="0"去除页面边框 list-style-type:none;去除li点 "color:red;text-decoration:none...
默认情况下, 如果没有指定context参数,$()将在当前的 HTML 文档中查找 DOM 元素;如果指定了 context 参数,如一个 DOM 元素集或 jQuery 对象,那就会在这个 context 中查找。 参考 Selectors 获取更多用于 ...
页面没有指定charset , Apache配置defaultcharst gbk , 页面文件编码是utf-8结果: 乱码,使用wireshark抓包,发现服务器返回的header中指明了:复制代码 代码如下:Content-Type:text/html;charset=GB结论:当页面...
ajax乱码解决总结 第一,javascript沿用java的字符处理方式,内部是使用...PHP:header('Content-Type:text/html;charset=GB2312'); ASP:Response.Charset("GB2312") JSP:response.setHeader("Charset","GB2312");
2、页面没有指定浏览器编码的显示方式,这一点解决的办法是:1,如果页面是.html需要设置<meta http-equiv=”Content-Type” content=”text/html; charset=utf8“/>,2如果是 x.php 的文件需要在头部加header...
meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>www.jb51.net js指定区域全屏</title> <style> #fulldiv { background: #fff; width: 100%; text-align:...
一般该伪类都会结合content一起使用,通过content可以向指定位置添加内容 属性选择器 根据元素的属性选择指定元素 [属性名] 选取含有指定属性的元素 [属性名="属性值"] 选取属性值等于指定值的元素 [属性...
页面编码统一 MySQL数据库编码、html页面编码、PHP或html文件本身编码要全部一致。 1、MySQL数据库编码: 建立数据库时指定编码(如gbk_...meta http-equiv=”Content-Type” content=”text/html; charset=gbk”
meta http-equiv=”Content-Type” content=”text/html; charset=GBK”><title>404 Not Found</title></head><body> 找不到指定的页面 ”totalSecond”>3秒后自动返回</body>&...
首先用js控制生成了一个组织结构图 再设置这个组织结构可以任意拖动到指定位置 页面代码如下 具体代码 实例 可以去我资源空间下载 代码如下: <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” ...
meta http-equiv="Content-Type" content="text/html; charset=GB18030"> <title>File upload</title> </head> <body> //必须是multipart的表单数据。 <form name="myform" action...
ScrollTo:平滑滚动到页面指定位置</title> <link rel=”stylesheet” type=”text/css” href=”../css/main.css” /> <style type=”text/css”> .nav{width:500px;margin:10px auto;} .nav li{...
--也就是说生成的input的type不能是"submit",而这个限制在有些情况下是不可原谅的。 --我们做了优化,现在要使一个Asp.net的按钮能够AJAX提交,你不需要做任何设置(PageManager的属性EnableAjax为true即可,这...
//这个模板就是自己声明的,即content_list.html,如果采用自定义模板的话,页面中可以只写上标签,并添加上标签内需要的几个参数,不需要写标签体的内容,会去自动调用模板中的标签体。 FrontUtils.includeTpl(TPL...