①. The page files are correctly encoded. gb2312 adopts ANSI and UTF-8;
②. Set the correct CODEPAGE in ASP code. Use 936 for gb2312 and 65001 for UTF-8;
③ Set the correct charset in the HTML code. Use gb2312 and UTF-8 for gb2312;
④. Encode the passed parameter values using the js escape function;
Sample Code
T1.asp (ANSI code ):
Copy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "936" %>
<% Session. CodePage = 936%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> Page (gb2312) -jb51.net </title>
</Head>
<Body>
<Script type = "text/javascript">
Document. write ("<a href = 't2. asp? Keyword = "+ escape (" wooden house ") +" '> wooden house </a> ");
</Script>
<Br/>
<%
Response. Write (Request. QueryString ("keyword "))
%>
</Body>
</Html>
T2.asp (UTF-8 encoding ):
Copy codeThe Code is as follows: <% @ LANGUAGE = "VBSCRIPT" CODEPAGE = "65001" %>
<% Session. CodePage = 65001%>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> Page (UTF-8) -jb51.net </title>
</Head>
<Body>
<Script type = "text/javascript">
Document. write ("<a href = 'T1. asp? Keyword = "+ escape (" wooden house ") +" '> wooden house </a> ");
</Script>
<Br/>
<%
Response. Write (Request. QueryString ("keyword "))
%>
</Body>
</Html>