JavaScript hints unterminated string literal error

Source: Internet
Author: User

Error prompted unterminated string literal, mainly because the output in JS contains N. The solution is to first take the data in the following way to remove N, and then pass the value of JS.

The code is as follows Copy Code

public static string Myreplace (String mystr)
{
MyStr = mystr. Replace ("Nr", "<br>&nbsp;&nbsp;"); /Note The order of the/r/n here, this is the wrong writing or error
MyStr = mystr. Replace ("RN", "<br/>&nbsp;&nbsp;"); /This is the right thing!
MyStr = mystr. Replace ("T", "&nbsp;&nbsp;&nbsp;&nbsp;");
MyStr = mystr. Replace ("", "&nbsp;");
MyStr = mystr. Replace ("<", "&lt;");
MyStr = mystr. Replace (">", "&gt;");
MyStr = mystr. Replace ("&", "&amp");

return mystr;

}

Replace line wrapping in asp:


1 Str=replace (Str,vbcrlf, "", 1,-1,1)

Replace line wrap in PHP:

The code is as follows Copy Code

1 $str = Str_replace ("n", "", $str);

2 $str = Str_replace ("R", "", $str);

The document.write (str) output is then performed.

If it is a single double quotation mark, we can replace or directly escape the

  code is as follows copy code

s= S.replace ("" "," \ "+" ");//

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.