


Detailed explanation to solve the problem of alert pop-up box displaying Chinese garbled characters when JavaScript is introduced
May 28, 2018 pm 01:52 PMWhen I introduced a JavaScript file into HTML today and ran it, the Chinese text in the alert box that popped up was garbled. How to solve this problem? The following editor brings you a solution to the problem that the alert pop-up box displays garbled Chinese characters when JavaScript is introduced. Let’s take a look.
Today, when a JavaScript file is introduced into HTML and run, the alert pop-up box displays Chinese characters as Garbled characters.
After investigation, there are two possibilities:
1. JavaScript and HTML file encoding methods are different
Method: Specify the character set as gb2312 in the code that introduces JavaScript. The code is as follows:
<script charset="gb2312" type="text/javascript" language="javascript" src="javascript.js"></script>
2. The encoding method of HTML does not support the display of Chinese
Method: In <head>< Add a <meta> tag to /head> and specify the HTML encoding format to be UTF-8. The code is as follows:
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
The above is the detailed content of Detailed explanation to solve the problem of alert pop-up box displaying Chinese garbled characters when JavaScript is introduced. For more information, please follow other related articles on the PHP Chinese website!

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement an online speech recognition system using WebSocket and JavaScript

Recommended: Excellent JS open source face detection and recognition project

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS

WebSocket and JavaScript: key technologies for implementing real-time monitoring systems

How to implement an online reservation system using WebSocket and JavaScript

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts

How to use JavaScript and WebSocket to implement a real-time online ordering system

JavaScript and WebSocket: Building an efficient real-time weather forecasting system
