JavaScript Traditional Chinese Conversion code

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Web Effects Traditional Chinese conversion code </title>

<body>

<a href= "#" Name= "Stranlink" > Traditional Chinese </a>
People's Republic of China
<script language= "Web Effects" type= "Text/javascript" >
var default_isft = 0; Default is traditional, 0-simplified, 1-Traditional
var stranit_delay = 50//Translation delay millisecond (this is designed to let the Web page appear smoothly first)
--code start, do not change the following
Convert text
function Strantext (txt,toft,chgtxt)
{
if (txt== "" | | Txt==null) return ""
Toft=toft==null?bodyisft:toft
if (chgtxt) txt=txt.replace (Toft?) Jane ":" (Toft?) Fan ":" Jane "))
if (Toft) {return traditionalized (TXT)}
else {return simplized (TXT)}
}
converting objects, using recursion, stripping layers to text
function Stranbody (fobj)
{
if (typeof (fobj) = = "Object") {var obj=fobj.childnodes}
Else
{
var tmptxt=stranlink_obj.innerhtml.tostring ()
if (Tmptxt.indexof ("Jane") <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 settings
{
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 Read
{
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 (offset, end) (document.cookie.substring)
}
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")//Non IE browser
{
Href= ""
}
Else
{
href= "#";
onclick= new Function ("Stranbody (); return false")
}
Title=strantext ("Traditional Chinese", 1, 1)
Innerhtml=strantext (innerhtml,1,1)
}
if (bodyisft== "1") {settimeout ("stranbody ()", Stranit_delay)}
}
</script>
</body>

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.