Javascript errors caused by a code

Source: Internet
Author: User

When creating a website background, a function referenced by the webpage to delete a product is in IE6, and IE7 cannot be executed. IE6 IE7 of dog blood does not have a console like chrome, so debugging is very troublesome. It only gives an approximate number of lines, and the object undefined.

Since it can be executed in chrome, ie9, ff, and fails in IE6 and IE7, the first thing that comes to mind is compatibility. But all functions are implemented using jquery. Except for confirm (), there should be no compatibility issues. So I came up with another idea: the website is based on frameset. Can I reference Js in the frame page and cannot be called in the sub-frame? Therefore, changing the original onclick = "deleteproduct ()" to onclick = "window. Top. Frames [2]. deleteproduct ()" does not work.

So we can debug it one by one sentence. Delete all the code in Admin. js and click "strong" on the page (using thinapp IE6 in Windows 7 does not force the new JS version to be obtained. It is depressing that the cached file can only be deleted each time ). Trace an IF (! Confirm ("are you sure you want to delete the check box? ") {Return false. However, the syntax does not look like there are errors, but it is normal to go through this sentence. When this sentence is added, the webpage reports "unfinished string constants ", the question must be in this sentence. After a Google attack, I found it was a coding problem.

The cause is that all my frameset files are HTML files. The file is ANSI encoded when DW is created. The charset in Meta is gb2312, while the JS file is UTF-8. When loading JS, the Js of utf8 is loaded into the DOM of gb2312, And the String constant ends.

Therefore, all frame files are resaved as UTF-8 and the charset in Meta is modified to UTF-8. The problem is solved.

Summary:

1. Google usually has a problem, but it seems that no one has ever encountered it. It can hardly be said that this problem is a pseudo problem.

2. the IE prompt is still a bit useful. If I can google "unfinished string constants" early, it is estimated that it has been solved for a long time.

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.