上图:
注意下面的代码,最好保存为utf-8格式的,要不容易出现乱码。
复制代码 代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript 金山词霸在线网络翻译 </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>
注意下面的代码,最好保存为utf-8格式的,要不容易出现乱码。
复制代码 代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript 金山词霸在线网络翻译 </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>
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“javascript实现的基于金山词霸网络翻译的代码”评论...
更新动态
2024年11月15日
2024年11月15日
- BIGFOUR.2013-大家利事【寰亚】【WAV+CUE】
- 李美凤.1992-情深透全情歌集【EMI百代】【WAV+CUE】
- 田震2024-《时光音乐会》[金峰][WAV+CUE]
- 群星《监听天碟3》[LECD]限量版[WAV+CUE]
- 心妤《声如夏花HQ》头版限量编号[WAV+CUE]
- 群星《摇滚五杰》[低速原抓WAV+CUE][1.1G]
- 群星 《2024好听新歌30》十倍音质 U盘音乐 [WAV+分轨]
- 群星《试音草原·女声篇》经典蒙古民歌[WAV+CUE][1G]
- 陈慧娴《永远是你的朋友》头版限量编号MQA-UHQCD2024[低速原抓WAV+CUE]
- 曼丽·女人三十《如果·爱》限量1:1母盘直刻[低速原抓WAV+CUE]
- 刘文正《流金三十年》[6N纯银镀膜][低速原抓WAV+CUE]
- 赵传.1994-精挑细选精选集【滚石】【WAV+CUE】
- 郑亚弦.2024-隔壁包厢603(EP)【发现梦想】【FLAC分轨】
- 文章.2004-被遗忘的时光【华博音乐】【WAV+CUE】
- 群星《青葱韶歌》原力计划·毕业季企划合辑[FLAC+分轨][661M]