Home  >  Article  >  Web Front-end  >  The solution to the garbled problem of page js is and the situation that cannot be transcoded_javascript skills

The solution to the garbled problem of page js is and the situation that cannot be transcoded_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:50:281215browse

I encountered a difficult problem today. Adding some js files to an old project was inconsistent with the encoding format of the old project, resulting in garbled characters. The old page is GB2312, the linked js file is UTF-8, and neither file can be converted.

The first idea is to convert the Chinese in the js file to unicode encoding. This approach is based on sacrificing readability, and all Chinese characters become passwords.

After thinking about it, there should be a better way, and then go to Baidu. The method is as follows:

Copy code The code is as follows:



Add the red setting, which means specifying the encoding format of the js file. This method is also suitable for situations where front-end personnel cannot transcode js files dynamically generated by the server, and js files of other people's websites that are loaded cross-domain.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn