IE8 message: The string constant is not closed

Source: Internet
Author: User

Error message:

Page Error Details:

Web page Error Details

user agent: mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; trident/4.0; SLCC2. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. net4.0e; infopath.2) Timestamp
: Tue, APR 2013 10:11:20 UTC


message: Not closed string constant
line:
0 characters:
Host:7001/survey/rms/task/loadtask.do


Solution:

Not-ended string constant page error

Not-closed string constants page errors are roughly divided into the following three situations:

(1) The encoding type of JavaScript and JSP file is inconsistent

Phenomenon: For example, your JSP Web page used in the encoding format is UTF-8, but your JS file with the encoding is GB2312, so that the file internal special characters because of inconsistent format will be decoded in the decoding, resulting in the compiler before the quotation mark before the end, resulting in "not end string Constants" This is not too easy to find mistakes.

Solution: If your JS is external reference, not written on the JSP page, you can <script type= "Text/javascript" src= "Xxx.js" charset= "###" > Set charset= "# # # "It's consistent with your JSP page code." If your JS is directly encoded on the JSP page, basically excludes this type of error.

(2) in JavaScript, strings are not matched or nested incorrectly

Phenomenon: This is the most common and most easily found error, either the single or double quotes in the string do not match, or when document.write (), the single or double quotes are not correctly printed, and there is an error when nested in single double quotes.

FIX: Put the front and back quotes correctly paired. When a total of two layers are nested, double quotes are nested within the set of single quotes; single quotes nested double quotes are correct. When there are three levels of nesting, the innermost quotation marks are the same as the outermost layer, which is wrong, and can be preceded by an escape character "\" in the innermost quotation mark.

(3) inside the parameter variable passed or the JSP script variable contains the HTML markup language, which contains a newline character or contains quotation marks

Phenomenon: This situation is the most difficult to find, easy to ignore the variable internal text causes, the string as a parameter passed to a function or HREF, action, the string contains line breaks, quotes or HTML tags, causing this error.

Workaround: In this case, there are two solutions: one is to replace the string variable. Replace double quotes with single quotes, and single quotes instead of "\", but they will be replaced with the original text when they are passed, and the other method is to not pass the data directly as a parameter, but to assign it to a hidden text first , the function simply reads the contents of the text.

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.