Page JS encountered garbled problem solving method is and can not transcoding the situation _javascript skills

Source: Internet
Author: User
Today encountered a thorny problem, in the old project Riga some JS files and old project coding format inconsistencies appear garbled. The old page is GB2312, the link into the JS file is UTF-8, two files can not be transferred format.

The first idea is to convert the Chinese in the JS file to Unicode encoding. This approach is based on the expense of readability of the conditions, the Chinese all become a password.

Afterwards think that there should be a better way, and then go to Baidu, the following methods:
Copy Code code as follows:

<script type= ' text/javascript ' src= ' xxxuft.js ' charset= ' utf-8 ' ></script>

Add the red setting, which means specifying the encoding format for the JS file. This method is also suitable for the server-side dynamically generated JS file front-end personnel can not transcoding, and cross-domain loading of other people's Web site JS files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.