<!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>網頁特效 繁體中文轉換代碼</title>
</head>
<body>
<a href="#" name="stranlink">繁體中文</a>
中華人民共和國
<script language="網頁特效" type="text/javascript">
var default_isft = 0; 預設是否繁體,0-簡體,1-繁體
var stranit_delay = 50 //翻譯延時毫秒(設這個的目的是讓網頁先流暢的顯現出來)
//-------代碼開始,以下別改-------
//轉換文本
function straNtext(txt,toft,chgtxt)
{
if(txt==""|| txt==null)return ""
toft=toft==null?bodyisft:toft
if(chgtxt)txt=txt.replace((toft?" 簡":"繁"),(toft?" 繁":"簡"))
if(toft){return traditionalized(txt)}
else {return simplized(txt)}
}
//轉換物件,使用遞迴,逐層剝到文本
function stranbody(fobj)
{
if(typeof(fobj)=="object"){var obj=fobj.childnodes}
else
{
var tmptxt=stranlink_obj.innerhtml.tostring()
if(tmptxt.indexof("簡")<0)
{
bodyisft=1
stranlink_obj.innerhtml=straNtext(tmptxt,0,1)
stranlink.title=straNtext(stranlink.title,0,1)
}
else
{
bodyisft=0
stranlink_obj.innerhtml=straNtext(tmptxt,1,1)
stranlink.title=straNtext(stranlink.title,1,1)
}
setcookie(jf_cn,bodyisft,7)
var obj=document.body.childnodes
}
for(var i=0;i<obj.length;i++)
{
var oo=obj.item(i)
if("|| br|hr|textarea|". indexof("|" +oo.tagname+"|") >0|| oo==stranlink_obj)continue;
if(oo.title!=""&&oo.title!=null)oo.title=straNtext(oo.title);
if(oo.alt!=""&&oo.alt!=null)oo.alt=straNtext(oo.alt);
if(oo.tagname=="input"&&oo.value!=""&&oo.type!="text"&&oo.type!="hidden")oo.value= straNtext(oo.value);
if(oo.nodetype==3){oo.data=straNtext(oo.data)}
else stranbody(oo)
}
}
function jtpystr()
{
return '';
}
function ftpystr()
{
return '';
}
function traditionalized(cc){
var str='',ss=jtpystr(),tt=ftpystr();
for(var i=0;i<cc.length;i++)
{
if(cc.charcodeat(i)>10000&&ss.indexof(cc.charat(i))!=-1)str+=tt.charat(ss.indexof(cc.charat(i)) );
else str+=cc.charat(i);
}
return str;
}
function simplized(cc){
var str='',ss=jtpystr(),tt=ftpystr();
for(var i=0;i<cc.length;i++)
{
if(cc.charcodeat(i)>10000&&tt.indexof(cc.charat(i))!=-1)str+=ss.charat(tt.indexof(cc.charat(i)) );
else str+=cc.charat(i);
}
return str;
}
function setcookie(name, value) //cookies設置
{
var argv = setcookie.arguments;
var argc = setcookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
if(expires!=null)
{
var largeexpdate = new date ();
largeexpdate.settime(largeexpdate.gettime() + (expires*1000*3600*24));
}
document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +largeexpdate.togmtstring()));
}
function getcookie(name) //cookies讀取
{
var search = name + "="
if(document.cookie.length > 0)
{
offset = document.cookie.indexof(search)
if(offset != -1)
{
offset += search.length
end = document.cookie.indexof(";", offset)
if(end == -1) end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
else return ""
}
}
var stranlink_obj=document.getelementbyid("stranlink")
if (stranlink_obj)
{
var jf_cn="ft"+self.location.hostname.tostring().replace(/./g,"")
var bodyisft=getcookie(jf_cn)
if(bodyisft!="1")bodyisft=default_isft
with(stranlink_obj)
{
if(typeof(document.all)!="object") //非ie瀏覽器
{
href=""
}
else
{
href="#";
onclick= new function("stranbody();return false")
}
title=straNtext("繁體中文",1,1)
innerhtml=straNtext(innerhtml,1,1)
}
if(bodyisft=="1"){settimeout("stranbody()",stranit_delay)}
}
</script>
</body>
</html>