Solve the problem of "introduction of js file IE6 error"
Problem description:
The page introduces a JS file that defines the function or object, and then when the function or object is called in the page, the "grammar error" or "lack of objects" will be reported in IE6. It runs normally in IE6+or IE7.
Problem analysis:
This object exists in the introduced JS file, because browsers above IE6+can run normally. This problem lies in the file encoding. If the JS file encoding is inconsistent with the coding of the current page, it may cause the pages in IE6 to be unable to obtain and analyze the content in the JS file. of. In the browser above IE6+, the general browser will automatically identify the encoding of each external file and analyze it;
Problem solution:
One: Add the charset attribute when introducing the JS file, keeping the same coding as the page;
Two: Modify the introduction of the file encoding format;
3: Create a new file format with the same page encoding format, copy and paste content;
(Personally recommend the third method, but it is recommended to add the Charset attribute when importing JS!)
Discover problems:
Due to the reinstalled system, after the project was published, it was found that JS reported an error: there is still a lack of objects in the report of the law. depressed
In the past, the system was IE7. After the reinstalled system was IE6. At first, I thought it was a browser version problem, and I thought that there was an incomparable code in the JS imported JS! So in the end, the JS line was annotated. When the JS file was deleted in the end, the above error appeared. ------ Super depression
In the past, the code was fine, how to reinstall a system is broken ~ Finally, I found out that the previous project was released. There was no error under IE6. The code was exactly the same. -------------------------------------------------------------------------------------- very depressing the word?
After thinking about it for a long time, thinking about the coding problem. The previous project coding was GB2312, and now the project is changed to UTF-8
<script language = "javascript" type = "text/javascript" src = "xx.js" charset = "uTF-8"> </script>
After adding it, it did not work, and then the coding format was changed to UTF-8 and it would not work. Finally, a new JS file encoding format is changed to UTF-8 and released OK.
Dizzy, generally encoding modification (1). Add charSet. (2). Modify the file encoding format. I also went to Tomcat to view it and have been modified. I don't know what's going on!
May be deleted and released! Intersection Intersection However, the problem is finally solved ~ If the system is not reinstalled, I can't find this little bug
---- Remember to prevent this error from happening!