javascript alert function displays Chinese garbled solutions: 1. When introducing javascript code into html, specify its character set as gb2312; 2. Add an attribute setting to the head of the html code and specify the html code The encoding format is [utf-8].
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
javascript alert function displays Chinese garbled solution:
Possible reason one:
If javascript is written in a The call made in the file may be because the encoding of js is inconsistent with our HTML encoding.
Solution:
When introducing javascript code into html, specify its character set as gb2312 to display Chinese. The code is as follows:
<script charset="gb2312" language="javascript" type="text/javascript" src="ntkoocx.js"></script>
Possible reason two:
The encoding format of the HTML webpage does not support the display of Chinese.
Solution:
Add an attribute setting to the header of the html code and specify the encoding format of the html code as utf-8 to support Chinese display. The code is as follows:
<html meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Related free learning recommendations: javascript video tutorial
The above is the detailed content of What should I do if the javascript alert function displays Chinese garbled characters?. For more information, please follow other related articles on the PHP Chinese website!