js 간 체 번 체 변환
"en">
"UTF-8">
"javascript: zh tran ('s');" class = "zh click" id = "zh click s" > 간 체 중국어 | "javascript: zh tran ('t');" class = "zh click" id = "zh click t" > 번 체 중국어
10 년 의 생사 가 막막 하 다.생각 하지 않다.잊 을 수 없다.천리 외 로 운 무덤 에 서 는 처량 한 말 을 할 곳 이 없다.설령 만 나 더 라 도 모 를 것 이 고, 먼지 가 얼굴 에 가득 하 더 라 도, 귀 밑 머리 는 서리 와 같다. 밤 에 깊 은 꿈 을 꾸다 가 갑자기 고향 으로 돌아가다.작은 창문.화장 을 하고 있다.서로 돌 보아 도 말 이 없고 눈물 만 천 번 흐른다.해마다 창자 가 끊 어 지 는 곳, 밝 은 달 밤, 짧 은 송 강 을 예상 하 다.
"javascript: zh tran ('s');" id = "dd" > 간 체 테스트
<span style="color:#008000;">//</span><span style="color:#008000;"> -------------- --------------------
</span><span style="color:#008000;">//</span><span style="color:#008000;">s = simplified t = traditional n = normal </span>
<span style="color:#0000ff;">var</span> zh_default = <span style="color:#800000;">'</span><span style="color:#800000;">n</span><span style="color:#800000;">'</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> , </span>
<span style="color:#0000ff;">var</span> zh_choose = getQueryString(<span style="color:#800000;">"</span><span style="color:#800000;">ltype</span><span style="color:#800000;">"</span>); <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_expires = <span style="color:#800080;">7</span>; <span style="color:#008000;">//</span><span style="color:#008000;">cookie </span>
<span style="color:#0000ff;">var</span> zh_class = <span style="color:#800000;">'</span><span style="color:#800000;">zh_click</span><span style="color:#800000;">'</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> class ,id class + s/t/n </span>
<span style="color:#0000ff;">var</span> zh_style_active = <span style="color:#800000;">'</span><span style="color:#800000;">font-weight:bold; color:red;</span><span style="color:#800000;">'</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_style_inactive = <span style="color:#800000;">''</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_browserLang = <span style="color:#800000;">''</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_autoLang_t = <span style="color:#0000ff;">true</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_autoLang_s = <span style="color:#0000ff;">false</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_autoLang_alert = <span style="color:#0000ff;">false</span>; <span style="color:#008000;">//</span><span style="color:#008000;">
</span><span style="color:#008000;">//</span><span style="color:#008000;"> </span>
<span style="color:#0000ff;">var</span> zh_autoLang_msg = <span style="color:#800000;">'</span><span style="color:#800000;"> ,
1. UTF-8 , .
2. ,
3. ,
4. cookie </span><span style="color:#800000;">'</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">var</span> zh_autoLang_checked = <span style="color:#800080;">0</span>; <span style="color:#008000;">//</span><span style="color:#008000;"> , cookie 1, 2,
</span><span style="color:#008000;">//</span><span style="color:#008000;"> ,ie ,ff </span>
<span style="color:#0000ff;">var</span> zh_langReg_t = /^zh-tw|zh-hk$/<span style="color:#000000;">i;
</span><span style="color:#0000ff;">var</span> zh_langReg_s = /^zh-cn$/<span style="color:#000000;">i;
</span><span style="color:#008000;">//</span><span style="color:#008000;"> , </span>
<span style="color:#0000ff;">var</span> zh_s = <span style="color:#800000;">'</span><span style="color:#800000;"> </span><span style="color:#800000;">'</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">var</span> zh_t = <span style="color:#800000;">'</span><span style="color:#800000;"> </span><span style="color:#800000;">'</span><span style="color:#000000;">;
String.prototype.tran</span>=<span style="color:#000000;">function(){
</span><span style="color:#0000ff;">var</span><span style="color:#000000;"> s1,s2;
</span><span style="color:#0000ff;">if</span>(zh_choose==<span style="color:#800000;">'</span><span style="color:#800000;">t</span><span style="color:#800000;">'</span><span style="color:#000000;">){
s1 </span>=<span style="color:#000000;"> zh_s;
s2 </span>=<span style="color:#000000;"> zh_t;
}</span><span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span>(zh_choose==<span style="color:#800000;">'</span><span style="color:#800000;">s</span><span style="color:#800000;">'</span><span style="color:#000000;">){
s1 </span>=<span style="color:#000000;"> zh_t;
s2 </span>=<span style="color:#000000;"> zh_s;
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">this</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">var</span> a = <span style="color:#800000;">''</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">var</span> l = <span style="color:#0000ff;">this</span><span style="color:#000000;">.length;
</span><span style="color:#0000ff;">for</span>(<span style="color:#0000ff;">var</span> i=<span style="color:#800080;">0</span>;i<<span style="color:#0000ff;">this</span>.length;i++<span style="color:#000000;">){
</span><span style="color:#0000ff;">var</span> c = <span style="color:#0000ff;">this</span><span style="color:#000000;">.charAt(i);
</span><span style="color:#0000ff;">var</span> p =<span style="color:#000000;"> s1.indexOf(c);
a </span>+= p < <span style="color:#800080;">0</span> ?<span style="color:#000000;"> c : s2.charAt(p);
}
</span><span style="color:#0000ff;">return</span><span style="color:#000000;"> a;
}
</span><span style="color:#008000;">//</span><span style="color:#008000;"> url </span>
<span style="color:#000000;"> function getQueryString(name) {
</span><span style="color:#0000ff;">var</span> reg = <span style="color:#0000ff;">new</span> RegExp(<span style="color:#800000;">"</span><span style="color:#800000;">(^|&)</span><span style="color:#800000;">"</span> + name + <span style="color:#800000;">"</span><span style="color:#800000;">=([^&]*)(&|$)</span><span style="color:#800000;">"</span>, <span style="color:#800000;">"</span><span style="color:#800000;">i</span><span style="color:#800000;">"</span><span style="color:#000000;">);
</span><span style="color:#0000ff;">var</span> r = window.location.search.substr(<span style="color:#800080;">1</span><span style="color:#000000;">).match(reg);
</span><span style="color:#0000ff;">if</span> (r != <span style="color:#0000ff;">null</span>) <span style="color:#0000ff;">return</span> unescape(r[<span style="color:#800080;">2</span>]); <span style="color:#0000ff;">return</span> <span style="color:#800000;">'</span><span style="color:#800000;">s</span><span style="color:#800000;">'</span><span style="color:#000000;">;
}
function setCookie(name, value){
</span><span style="color:#0000ff;">var</span> argv =<span style="color:#000000;"> setCookie.arguments;
</span><span style="color:#0000ff;">var</span> argc =<span style="color:#000000;"> setCookie.arguments.length;
</span><span style="color:#0000ff;">var</span> expires = (argc > <span style="color:#800080;">2</span>) ? argv[<span style="color:#800080;">2</span>] : <span style="color:#0000ff;">null</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">if</span>(expires != <span style="color:#0000ff;">null</span><span style="color:#000000;">){
</span><span style="color:#0000ff;">var</span> LargeExpDate = <span style="color:#0000ff;">new</span><span style="color:#000000;"> Date ();
LargeExpDate.setTime(LargeExpDate.getTime() </span>+ (expires*<span style="color:#800080;">1000</span>*<span style="color:#800080;">3600</span>*<span style="color:#800080;">24</span><span style="color:#000000;">));
}
document.cookie </span>= name + <span style="color:#800000;">"</span><span style="color:#800000;">=</span><span style="color:#800000;">"</span> + escape (value)+((expires == <span style="color:#0000ff;">null</span>) ? <span style="color:#800000;">""</span> : (<span style="color:#800000;">"</span><span style="color:#800000;">; expires=</span><span style="color:#800000;">"</span> +<span style="color:#000000;">LargeExpDate.toGMTString()));
}
function getCookie(Name){
</span><span style="color:#0000ff;">var</span> search = Name + <span style="color:#800000;">"</span><span style="color:#800000;">=</span><span style="color:#800000;">"</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">if</span>(document.cookie.length > <span style="color:#800080;">0</span><span style="color:#000000;">){
offset </span>=<span style="color:#000000;"> document.cookie.indexOf(search);
</span><span style="color:#0000ff;">if</span>(offset != -<span style="color:#800080;">1</span><span style="color:#000000;">){
offset </span>+=<span style="color:#000000;"> search.length;
end </span>= document.cookie.indexOf(<span style="color:#800000;">"</span><span style="color:#800000;">;</span><span style="color:#800000;">"</span><span style="color:#000000;">, offset);
</span><span style="color:#0000ff;">if</span>(end == -<span style="color:#800080;">1</span><span style="color:#000000;">){
end </span>=<span style="color:#000000;"> document.cookie.length;
}
</span><span style="color:#0000ff;">return</span><span style="color:#000000;"> unescape(document.cookie.substring(offset, end));
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
</span><span style="color:#0000ff;">return</span> <span style="color:#800000;">''</span><span style="color:#000000;">;
}
}
}
function zh_tranBody(obj){
</span><span style="color:#0000ff;">var</span> o = (<span style="color:#0000ff;">typeof</span>(obj) == <span style="color:#800000;">"</span><span style="color:#800000;">object</span><span style="color:#800000;">"</span>) ?<span style="color:#000000;"> obj.childNodes : document.body.childNodes;
</span><span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">var</span> i = <span style="color:#800080;">0</span>; i < o.length; i++<span style="color:#000000;">){
</span><span style="color:#0000ff;">var</span> c =<span style="color:#000000;"> o.item(i);
</span><span style="color:#0000ff;">if</span>(<span style="color:#800000;">'</span><span style="color:#800000;">||BR|HR|TEXTAREA|SCRIPT|</span><span style="color:#800000;">'</span>.indexOf(<span style="color:#800000;">"</span><span style="color:#800000;">|</span><span style="color:#800000;">"</span>+c.tagName+<span style="color:#800000;">"</span><span style="color:#800000;">|</span><span style="color:#800000;">"</span>) > <span style="color:#800080;">0</span>) <span style="color:#0000ff;">continue</span><span style="color:#000000;">;
</span><span style="color:#0000ff;">if</span>(c.className ==<span style="color:#000000;"> zh_class){
</span><span style="color:#0000ff;">if</span>(c.id == zh_class + <span style="color:#800000;">'</span><span style="color:#800000;">_</span><span style="color:#800000;">'</span> +<span style="color:#000000;"> zh_choose){
c.setAttribute(</span><span style="color:#800000;">'</span><span style="color:#800000;">style</span><span style="color:#800000;">'</span><span style="color:#000000;">, zh_style_active);
c.style.cssText </span>=<span style="color:#000000;"> zh_style_active;
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
c.setAttribute(</span><span style="color:#800000;">'</span><span style="color:#800000;">style</span><span style="color:#800000;">'</span><span style="color:#000000;">, zh_style_inactive);
c.style.cssText </span>=<span style="color:#000000;"> zh_style_inactive;
}
</span><span style="color:#0000ff;">continue</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">if</span>(c.title != <span style="color:#800000;">''</span> && c.title != <span style="color:#0000ff;">null</span><span style="color:#000000;">){
c.title </span>=<span style="color:#000000;"> c.title.tran();
}
</span><span style="color:#0000ff;">if</span>(c.alt != <span style="color:#800000;">''</span> && c.alt != <span style="color:#0000ff;">null</span><span style="color:#000000;">){
c.alt </span>=<span style="color:#000000;"> c.alt.tran();
}
</span><span style="color:#0000ff;">if</span>(c.tagName == <span style="color:#800000;">"</span><span style="color:#800000;">INPUT</span><span style="color:#800000;">"</span> && c.value != <span style="color:#800000;">''</span> && c.type != <span style="color:#800000;">'</span><span style="color:#800000;">text</span><span style="color:#800000;">'</span> && c.type != <span style="color:#800000;">'</span><span style="color:#800000;">hidden</span><span style="color:#800000;">'</span> && c.type != <span style="color:#800000;">'</span><span style="color:#800000;">password</span><span style="color:#800000;">'</span><span style="color:#000000;">){
c.value </span>=<span style="color:#000000;"> c.value.tran();
}
</span><span style="color:#0000ff;">if</span>(c.nodeType == <span style="color:#800080;">3</span><span style="color:#000000;">){
c.data </span>=<span style="color:#000000;"> c.data.tran();
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
zh_tranBody(c);
}
}
}
function zh_tran(go){
</span><span style="color:#0000ff;">if</span>(go) zh_choose =<span style="color:#000000;"> go;
setCookie(</span><span style="color:#800000;">'</span><span style="color:#800000;">zh_choose</span><span style="color:#800000;">'</span><span style="color:#000000;">, zh_choose, zh_expires);
</span><span style="color:#0000ff;">if</span>(go == <span style="color:#800000;">'</span><span style="color:#800000;">n</span><span style="color:#800000;">'</span><span style="color:#000000;">){
window.location.reload();
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;"> {
zh_tranBody();
}
}
function zh_getLang(){
</span><span style="color:#0000ff;">if</span>(getCookie(<span style="color:#800000;">'</span><span style="color:#800000;">zh_choose</span><span style="color:#800000;">'</span><span style="color:#000000;">)){
zh_choose </span>= getCookie(<span style="color:#800000;">'</span><span style="color:#800000;">zh_choose</span><span style="color:#800000;">'</span><span style="color:#000000;">);
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">true</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">if</span>(!zh_autoLang_t && !<span style="color:#000000;">zh_autoLang_s){
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">if</span>(getCookie(<span style="color:#800000;">'</span><span style="color:#800000;">zh_autoLang_checked</span><span style="color:#800000;">'</span><span style="color:#000000;">)){
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">if</span><span style="color:#000000;">(navigator.language){
zh_browserLang </span>=<span style="color:#000000;"> navigator.language;
}</span><span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span><span style="color:#000000;">(navigator.browserLanguage){
zh_browserLang </span>=<span style="color:#000000;"> navigator.browserLanguage;
}
</span><span style="color:#0000ff;">if</span>(zh_autoLang_t &&<span style="color:#000000;"> zh_langReg_t.test(zh_browserLang)){
zh_choose </span>= <span style="color:#800000;">'</span><span style="color:#800000;">t</span><span style="color:#800000;">'</span><span style="color:#000000;">;
}</span><span style="color:#0000ff;">else</span> <span style="color:#0000ff;">if</span>(zh_autoLang_s &&<span style="color:#000000;"> zh_langReg_s.test(zh_browserLang)){
zh_choose </span>= <span style="color:#800000;">'</span><span style="color:#800000;">s</span><span style="color:#800000;">'</span><span style="color:#000000;">;
}
zh_autoLang_checked </span>= <span style="color:#800080;">1</span><span style="color:#000000;">;
setCookie(</span><span style="color:#800000;">'</span><span style="color:#800000;">zh_choose</span><span style="color:#800000;">'</span><span style="color:#000000;">, zh_choose, zh_expires);
</span><span style="color:#0000ff;">if</span>(zh_choose ==<span style="color:#000000;"> zh_default){
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">false</span><span style="color:#000000;">;
}
</span><span style="color:#0000ff;">return</span> <span style="color:#0000ff;">true</span><span style="color:#000000;">;
}
function zh_init(){
zh_getLang();
c </span>= document.getElementById(zh_class + <span style="color:#800000;">'</span><span style="color:#800000;">_</span><span style="color:#800000;">'</span> +<span style="color:#000000;"> zh_choose);
</span><span style="color:#0000ff;">if</span>(zh_choose !=<span style="color:#000000;"> zh_default){
</span><span style="color:#0000ff;">if</span><span style="color:#000000;">(window.onload){
window.onload_before_zh_init </span>=<span style="color:#000000;"> window.onload;
window.onload </span>=<span style="color:#000000;"> function(){
zh_tran(zh_choose);
</span><span style="color:#0000ff;">if</span><span style="color:#000000;">(zh_autoLang_alert){
alert(zh_autoLang_msg);
};
window.onload_before_zh_init();
};
}</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
window.onload </span>=<span style="color:#000000;"> function(){
zh_tran(zh_choose);
</span><span style="color:#0000ff;">if</span><span style="color:#000000;">(zh_autoLang_alert){
alert(zh_autoLang_msg);
};
};
}
}
}
zh_init();
</span>
다음으로 전송:https://www.cnblogs.com/jianghaidong/p/10032222.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.