javascript 使用金山詞霸網路翻譯

來源:互聯網
上載者:User
<html><head><title>金山詞霸 -- 微型網路版</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.documentElement;    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.target;    $("text_word").value = element.innerHTML;    button_translateClick();}</script><input id="text_word" type="text" value="hello" onkeydown="text_wordKeydown(event)" /><input type="button" value="翻譯" 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>

 

啥也不說了 :

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.