Home>Article>Web Front-end> What to do if alert is garbled in javascript
Solution to garbled alert code in JavaScript: 1. Add "charset=utf-8"" to the
part of the HTML; 2. Add "charset="gb2312" to the
## The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.
What should I do if alert is garbled in javascript?
Alert in js external script Solution to Chinese garbled characters
I encountered a problem while working on a project. When I switched to using external references from the js script written in the html document, I found that the Chinese in alert() became Garbled characters. The page already contains
charset="gb2312"# to the
##Method 3. The most fundamental way is to change the saving encoding of the js external script to utf8: When opening it with the editor, click Save As and select Unicode UTF-8, as shown below:
About the difference between signed and unsigned: When the signed UTF-8 encoded content is parsed by the browser, the browser can determine that UTF-8 encoding is used for parsing directly based on the signature. When there is no signature, the browser will make a judgment based on the encoding of the content. In short, the signature will be easier for the browser to parse with the correct encoding. (This paragraph is excerpted from: UTF-8 Signature and Not The difference between signatures)
Recommended learning: "
JavaScript Video TutorialThe above is the detailed content of What to do if alert is garbled in javascript. For more information, please follow other related articles on the PHP Chinese website!