一、首先在网页最上面加入:
<%@ CODEPAGE=65001 %>
<% Response.CodePage=65001%>
<% Response.Charset="UTF-8" %>
记得每页都要加哦
二、
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
三:在首页你想出现“简体中文”、“繁体中文”的地方加入下面的语句
<a href="" id="translateLink">繁體中文</a>
<script type="text/javascript" src="tw_cn.js"></script>
<script type="text/javascript">
var defaultEncoding = 0; //默认是否繁体,0-简体,1-繁体
var translateDelay = 0; //延迟时间,若不在</body>前, 要设定延迟翻译时间, 如100表示100ms,默认为0
var cookieDomain = ""; //Cookie地址, 一定要设定, 通常为你的网址
var msgToTraditionalChinese = "繁體中文"; //默认切换为繁体时显示的中文字符
var msgToSimplifiedChinese = "简体中文"; //默认切换为简体时显示的中文字符
var translateButtonId = "translateLink"; //默认互换id
translateInitilization();
</script>
四、看到上面用红色显示的文件了吗?把下面的代码保存为tw-cn.js文件就可以了
var defaultEncoding = 2; // 1: Tranditional Chinese, 2: Simplified Chinese
var translateDelay = 0;
var cookieDomain = "自己的网址";//自己的网址
var msgToTraditionalChinese = "繁體";
var msgToSimplifiedChinese = "简体";
var translateButtonId = "translateLink";
var currentEncoding = defaultEncoding;
var targetEncodingCookie = "targetEncoding" + cookieDomain.replace(/\./g,"");
var targetEncoding = ( getCookie(targetEncodingCookie) == null ? defaultEncoding : getCookie(targetEncodingCookie) );
var translateButtonObject;
function translateText( txt )
{
if( txt == "" || txt == null )
return "";
if( currentEncoding == 1 && targetEncoding == 2 )
return Simplized(txt);
else if ( currentEncoding == 2 && targetEncoding == 1 )
return Traditionalized(txt);
else
return txt;
}
function translateBody( fobj )
{
if( typeof( fobj ) == "object" )
var objs = fobj.childNodes;
else
var objs = document.body.childNodes;
for(var i=0;i<objs.length;i++)
{
var obj=objs.item(i);
if( "||BR|HR|TEXTAREA|".indexOf( "|"+obj.tagName+"|" ) > 0 || obj == translateButtonObject )
continue;
if( obj.title != "" && obj.title != null )
obj.title = translateText( obj.title );
if( obj.alt != "" && obj.alt != null )
obj.alt = translateText( obj.alt );
if( obj.tagName == "INPUT" && obj.value != "" && obj.type != "text" && obj.type != "hidden" )
obj.value = translateText( obj.value );
if( obj.nodeType == 3 )
obj.data = translateText( obj.data );
else
translateBody(obj);
}
}
function translatePage()
{
if( targetEncoding == 1 )
{
currentEncoding = 1;
targetEncoding = 2;
translateButtonObject.innerHTML = msgToTraditionalChinese;
setCookie( targetEncodingCookie, targetEncoding, 7 );
translateBody();
}
else if( targetEncoding == 2 )
{
currentEncoding = 2;
targetEncoding = 1;
translateButtonObject.innerHTML = msgToSimplifiedChinese;
setCookie( targetEncodingCookie, targetEncoding,
···
···