Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:50:28
Original
1172 people have browsed it

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.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!