Introducing JS file IE6 to report syntax errors or lack of object solutions _ javascript tips-js tutorial

Source: Internet
Author: User
The introduction of JS file IE6 reports an error or a lack of objects. Many friends may have encountered this problem because of file encoding, the following describes a good solution to the problem of "Introducing the JS file IE6 error ".

Problem description:

The page introduces a js file that defines a function or object. When you call a function or object on the page, IE6 reports a "syntax error" or "Missing Object ". It runs normally in IE6 + or IE7.

Problem Analysis:

This object exists in the introduced JS file, because it can run normally in IE6 + or more browsers. This problem lies in the file encoding. If the JS file encoding is inconsistent with the current page encoding, the page in IE6 may fail to get and parse the content in the JS file normally. in IE6, the default file and page encoding are the same. In IE6 + browsers, browsers generally automatically recognize the encoding of each external file and parse it;

Solution:

1. Add the charset attribute to the js file to ensure consistency with the page encoding;
2. Modify the introduced file encoding format;
3. Create a new file in the same format as the page encoding. copy and paste the content;
(The third method is recommended, but we recommend that you add the charset attribute when importing Javascript !)

Problems found:

Due to the reinstallation of the system, the js error is found after the project is released: A syntax error is reported and there is still a lack of objects. Depressing
In the past, the system was ie7. After the system was reinstalled, it was ie6. at first thought it was a browser version problem and thought that the js imported from the page had ie6 incompatible code! So I finally commented out one line of js. When all the js files were deleted, the above error also occurred. ------ Super depressing
The code used to be okay. How can I reinstall a system ~ Finally, find out that the previous project was released. There is no error in ie6 and the code is exactly the same. ------------ Can I still use the word "depressing?
I thought about coding for half a day. Previously the project code was gb2312, and now the project is changed to UTF-8
Related Article

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.