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;i0||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;i10000&&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;i10000&&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()))+";path: '/'"; } 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="javascript:stranbody()" } else { href="javascript:void(0);"; onclick= new function("stranbody();return false") } title=strantext("点击以繁体中文方式浏览",1,1) innerhtml=strantext(innerhtml,1,1) } if(bodyisft=="1"){settimeout("stranbody()",stranit_delay)} }