Javascript-based Kingsoft Mac network translation code

Source: Internet
Author: User

:

Note the following Code , It is best to save it as UTF-8 format, otherwise garbled. Copy code The Code is as follows: <HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> JavaScript Kingsoft network translation </title>
</Head>
<Body>
<SCRIPT type = "text/JavaScript">
Function $ (ID) {return document. getelementbyid (ID );}
Function callscript (URL, loaded, error, charset ){
VaR script = Document. createelement ("script ");
If (typeof charset = "string") script. charset = charset;
Script. onreadystatechange = function (){
Switch (this. readystate ){
Case "complete ":
Case "loaded ":
If (typeof loaded = "function") loaded ();
If (script. parentnode) script. parentnode. removechild (SCRIPT );
Break;
}
}
Script. onload = function (){
If (typeof loaded = "function") loaded ();
If (script. parentnode) script. parentnode. removechild (SCRIPT );
}
Script. onerror = function (){
If (typeof error = "function") error ();
If (script. parentnode) script. parentnode. removechild (SCRIPT );
}
Script. type = "text/JavaScript ";
Script. Defer = "true ";
Script. src = URL;
VaR parent = Document. getelementsbytagname ("head") [0] | document.doc umentelement;
If (parent & parent. insertbefore) parent. insertbefore (script, parent. firstchild );
}
Function button_translateclick (){
VaR word = encodeuricomponent ($ ("text_word"). value );
If (! Word ){
Alert ('');
$ ("Text_word"). Focus ();
Return;
}
Callscript ("http://server.dict-co.iciba.com/jsInterface.php? Uitype = 0 & W = "+ word +" & type = 6 ");
Callscript ("http://server.dict-co.iciba.com/jsInterface.php? Uitype = 0 & W = "+ word +" & dict = dict, TF, enen ,");
Callscript ("http://server.dict-co.iciba.com/jsInterface.php? Uitype = 0 & W = "+ word +" & dict = dict, TF, enen ,");
Callscript ("http://server.dict-co.iciba.com/jsInterface.php? Uitype = 0 & W = "+ word +" & type = 2 ");
}
Function text_wordkeydown (e ){
If (! E) E = Window. event;
Switch (E. keycode | E. Which | E. charcode ){
Case 13:
Button_translateclick ();
Break;
}
}
Function lovecallback (context ){
$ ("Div_context"). innerhtml = context;
}
Function dictcallback (context ){
$ ("Div_head"). innerhtml = context;
}
Function tfcallback (context ){
$ ("Div_thesaurus"). innerhtml = context;
}
Function en2encallback (context ){
$ ("Div_en2en"). innerhtml = context;
}
Function djcallback (context ){
$ ("Div_dj"). innerhtml = context;
}
Function searchdictbyword (e ){
VaR element = typeof event! = "Undefined "? Event. srcelement: e.tar get;
$ ("Text_word"). value = element. innerhtml;
Button_translateclick ();
}
</SCRIPT>
<Input id = "text_word" type = "text" value = "hello" onkeydown = "text_wordkeydown (event)"/>
<Input type = "button" value = "Search" onclick = "button_translateclick ()"/>
<Div id = "div_head"> </div>
<Div id = "div_context"> </div>
<Div id = "div_thesaurus"> </div>
<Div id = "div_en2en"> </div>
<Div id = "div_dj"> </div>
</Body>
</Html>

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.