JavaScript Traditional Chinese Conversion code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax code cookie document function html http javascript

<!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= "HTML; Charset=utf-8 "/>
<title> Web Effects Traditional Chinese conversion code </title>

</head>

<body>

&lt;a href= "#" Name= "Stranlink" &gt; Traditional Chinese &lt;/a&gt;


People's Republic of China


&lt;script language= "Web Effects" type= "Text/javascript" &gt;


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)}


}  


//Convert object, use recursion, peel to text layers


function Stranbody (fobj)


{  


if (typeof (fobj) = = "Object") {var obj=fobj.childnodes}


Else


{  


var tmptxt=stranlink_obj.innerhtml.tostring ()


if (Tmptxt.indexof ("Jane") &lt;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&lt;obj.length;i++)


{  


var oo=obj.item (i)


if ("| | Br|hr|textarea| ". IndexOf ("|") +oo.tagname+ "|") &gt;0| |   Oo==stranlink_obj) re-enters;


if (oo.title!= "&amp;&amp;oo.title!=null) Oo.title=strantext (oo.title);


if (oo.alt!= "&amp;&amp;oo.alt!=null) Oo.alt=strantext (Oo.alt);


if (oo.tagname== "input" &amp;&amp;oo.value!= "" &amp;&amp;oo.type!= "text" &amp;&amp;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&lt;cc.length;i++)


{  


if (cc.charcodeat (i) &gt;10000&amp;&amp;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&lt;cc.length;i++)


{  


if (cc.charcodeat (i) &gt;10000&amp;&amp;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 set


{  


var argv = setcookie.arguments;


var argc = setcookie.arguments.length;


var expires = (argc &gt; 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 &gt; 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")//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)}





&lt;/script&gt;


&lt;/body&gt;


&lt;/html&gt;


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.