Home > Web Front-end > JS Tutorial > What should I do if the javascript alert function displays Chinese garbled characters?

What should I do if the javascript alert function displays Chinese garbled characters?

coldplay.xixi
Release: 2023-01-04 09:35:50
Original
2789 people have browsed it

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].

What should I do if the javascript alert function displays Chinese garbled characters?

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>
Copy after login

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" />
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template