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: