Solution to unending Javascript string constants

Source: Internet
Author: User

Summarize the "unended string constants" in javascript in the WEB program ".

1. When JAVASCRIPT is referenced, the character languages used are inconsistent.

For example, <script type = "text/javasAlias "src =" xxx. js "charset =" UTF-8 ">. xxx. js file is used inside the GB2312 format, calling outside is used UTF-8, so some special characters inside the file because of inconsistent formats, garbled, this cause.

Helper House: http://www.bkjia.com/

During the development process, I encountered that the js file contains a Chinese font, and the reference part of the js file did not specify the character set for calling the js file. All of these errors resulted in this error.

2. When JAVASCRIPT outputs HTML characters, the front and back labels do not match.

This is common. when outputting a string, single quotation marks (') or double quotation marks (") are not paired, or. when writing (), the single quotation mark (') or double quotation mark (") is not correctly output (")

3. HTML markup language or line break in the Parameter

This is the case I encountered today, because the data I got is passed to a function as a parameter. As a result, the data contains a line break, causing this error.

For example, it is normal to use only a single row of data during the test. This error is not reported ,.

This error occurs when multiple lines of data are used during the test and the carriage return link is used for line feed.

In 3rd cases, my solution is to assign a value to a hidden text instead of passing the data as a parameter, you only need to read the content in the text in the function to be called.

At first, I was confused about this error and it was difficult to debug it.

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.