question:
My blog code is utf-8. Sometimes when opening the page, it is blank, and refreshing it will be normal, but when viewing the source file is complete. Both under ie6 and firefox are normal, but this happens occasionally under ie7.
At first I suspected it was an IDC problem, but later I thought of js, css, page structure, etc. By chance I thought of coding. After all, the coding problem has not been troubled by me once or twice.
solve:
<title>Wulin.com</title>
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
Switch order
<meta http-equiv=Content-Type content=text/html; charset=gb2312 />
<title>LC'BLOG</title>
reason:
Why does this problem occur with only ie7? This is because when ie7 parses web encoding, the tags in the html are preferred, and then the messages in the http header are sent, while the browsers in the mozilla series are just the opposite.
Since the utf-8 encoded page represents a Chinese character with 3 bytes, the ordinary gb2313 or big5 are two. When outputting the page, due to the above reasons, when the browser parses and outputs the content of <title></title>, if there are odd full-width characters in front of the </title>, ie7 treats utf-8 as two bytes and half a Chinese character appears. At this time, the half Chinese character will be combined with the < of </title> into a garbled character, causing ie7 to be unable to read the <title> part, making the entire page empty and output. If you look at the source file at this time, you will find that the entire leaf surface has actually been output.
Therefore, the easiest solution is to place the character definition in the <head></head> tag of the web page file before the <meta http-equiv=Content-Type content=text/html; charset=UTF-8 /> in the <title></title>.
In fact, other encoding versions also have similar problems, but our browser default encoding is GBK, so it is even less likely to be noticed.