Reference external JS garbled problem analysis and solution _javascript skill

Source: Internet
Author: User
In the Web development we generally will inevitably use JS. We can put the JS code directly in the page that is, through the internal use of JS. But in order to give the page good "thin body" we will generally put the JS code outside, and then through SRC Reference. This time we need to pay attention to a problem: coding problems. If the Web page also uses different encoding JS, this time will appear garbled. (The internal use of JS does not need to pay attention to coding problems, because they are using the same encoding)

For most web pages, we generally use the following two kinds of code: UTF-8, GB2312. So we just need to agree with the page and JS code can solve the garbled problem:
If there is a garbled problem with a JavaScript file encoded with a GBK page reference encoded as UTF-8, you can use the following code to resolve
Copy Code code as follows:

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.