Introduced JS file IE6 to report syntax errors or missing object problems

  • 2020-03-30 01:16:55
  • OfStack

Fixed "imported JS file IE6 error" problem

Problem description:

The page introduces a js file that defines a function or object, and then when the function or object is called in the page, it will report a "syntax error" or "missing object" in IE6. It works fine in IE6+ or IE7.

Problem analysis:

This object exists in the incoming JS file because browsers above IE6+ will work fine. This problem lies in the file encoding. If the JS file encoding is not consistent with the current page encoding, it may lead to the page in IE6 can not normally get and parse the contents of the JS file, in IE6, the default introduced file and page encoding is consistent. In IE6+ + browsers, the browser will automatically recognize each external file encoding and parsing;

Problem solving:

1. Add charset property when introducing js file to keep consistent with the page code;
Ii. Modify the encoding format of the imported documents;
Three: create a new file format with the page code format, copy and paste the content;
(I personally recommend the third method, but I recommend adding the charset property when importing js!)

Problem detection:

Due to the reinstallation of the system, after publishing the project, js reported errors: syntax errors and missing objects. depressed
The previous system is ie7, after the reinstallation of the system for ie6. So the last line of js comments out, when the last js file is deleted, there is still the above error. -- super depressed
Before the code is also fine, how to reinstall a system is broken ~ finally found the previous project released, in ie6 under no errors, the code is exactly the same. -- I don't know if you can use the word depressed?
Thought for a long time, thought of the coding problem. Previously the project code was gb2312, now the project is utf-8
< Script language="JavaScript" type="text/ JavaScript" SRC =" xx. js" charset=" utf-8 "> < / script>
After the addition did not work, and then js the encoding format to utf-8 to run. Finally, create a new js file encoding format to utf-8, publish OK.
Dizzy, general code modification (1). Add charset. (2). Modify the file encoding format. Also go to tomcat to see that it has been modified. I don't know what happened!
May want to delete completely in the release!! However, the problem is finally solved ~ if you do not reinstall the system, still can not find this small bug
Make a note to prevent this kind of mistake from happening in the future!

Related articles: