When the ASPX page references the JS file, an error occurs when the Javascript statement contains Chinese characters.

Source: Internet
Author: User
A simple aspx file that references a JS File

<Script language = "JavaScript" src = "../JS/jscript1.js"> </SCRIPT>

The JS file statement contains Chinese characters.

Function Test ()
{
VaR mycode;
Mycode = "delete ";
Alert (mycode );
}

When you run the aspx file, the system prompts "uncompleted string constants". The error line is Var mycode. However, if you comment out mycode = "delete", the error will not occur.

Using an HTML file to reference this JS file will not cause errors. Save the HTML generated by aspx and compare it with the tested HTML file. The difference is mainly in the header section. The following is the header code generated by aspx:


<Meta http-equiv = Content-Type content = "text/html; charset = UTF-8">
<Meta content = "mshtml 6.00.00000.2577" name = generator>
<Meta content = C # name = code_language>
<Meta content = JavaScript name = vs_defaultclientscript>

This is part of the code for testing the HTML file header.


<Meta name = "generator" content = "Microsoft Visual Studio. NET 7.1">
<Meta name = "progid" content = "visualstudio. html">
<Meta name = "originator" content = "Microsoft Visual Studio. NET 7.1">

Change the uft-8 in the header of the HTML generated by aspx to gb2312
<Meta http-equiv = Content-Type content = "text/html; charset = gb2312">
Open the modified HTML directly, and the error disappears. However, if gb2312 is specified in Aspx. CS, the page will run garbled characters.

Headache!

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.