Introduction of JS file IE6 report syntax error or lack of object problem solving method _javascript Skills

Source: Internet
Author: User
Solve the problem of "Introducing JS file IE6 Error"

Problem Description:

The page introduces a JS file that defines a function or object, and then calls a function or object in the page, IE6 the "syntax error" or "Missing object". In ie6+ or IE7 it works fine.

Problem Analysis:

This object is present in the JS file being introduced, because browsers above ie6+ can run normally. The problem is file encoding, if the JS file encoding and the current page encoding inconsistent, it may lead to IE6 in the page can not be normal to obtain and parse the contents of JS file, in IE6, the default introduction of the file and page encoding is consistent. In ie6+ above browser, the general browser will automatically identify each external file encoding and parsing;

Problem Solving:

One: the introduction of JS file with charset attribute, keep the same as the page code;
Second: Modify the introduction of file encoding format;
Three: Create a new file format consistent with the page encoding format, copy and paste content;
(Personal suggestions for a third method, but it is recommended to import JS with the CharSet Property!) )

problem found:

Because of the reload system, post the project found JS error: reported grammatical errors and missing objects. Depressed
Before the system is IE7, after reloading the system for IE6. Just started to think that the browser version of the problem, the page to import JS inside there are IE6 incompatible code! So the last JS line of comments out, when the last JS files are all deleted, there are errors above. ------Super Depressed
Before the code is fine, how to reload a system is bad ~ finally find out the previous project released, in the IE6 without errors, the code exactly the same. ------------I don't know if I can use the word "depressed"?
Think for a long time, think of coding problems. The previous project was encoded as gb2312, and now the project is changed to UTF-8
<script language= "JavaScript" type= "Text/javascript" src= "Xx.js" charset= "UTF-8" > </script>
Add after no effect, and then to JS the encoding format changed to UTF-8 run also not. Finally a new JS file encoding format changed to Utf-8, release OK.
Faint death, General coding modification (1). Increase CharSet. (2). Modify the file encoding format. Also to Tomcat under the view has also been modified. I don't know what's going on!
may have to delete all in the release bar!!! But the problem is solved ~ if you do not reload the system, you can not find this small bug
----Write down to prevent this error from happening!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.