SoFunction
Updated on 2025-03-01

Code based on Kingsoft PowerWord Network translation implemented by javascript


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>javascript Kingsoft PowerWord Online Translation </title>
</head>
<body>
<script type="text/javascript">
function $(id) { return (id); }
function callScript(url, loaded, error, charset) {
var script = ("script");
if (typeof charset == "string") = charset;
= function() {
switch () {
case "complete":
case "loaded":
if (typeof loaded == "function") loaded();
if () (script);
break;
}
}
= function() {
if (typeof loaded == "function") loaded();
if () (script);
}
= function() {
if (typeof error == "function") error();
if () (script);
}
= "text/javascript";
= "true";
= url;
var parent = ("HEAD")[0] || ;
if (parent && ) (script, );
}
function button_translateClick() {
var word = encodeURIComponent($("text_word").value);
if (!word) {
alert('');
$("text_word").focus();
return;
}
callScript("/?uiType=0&w=" + word + "&type=6");
callScript("/?uiType=0&w=" + word + "&dict=Dict,Tf,Enen,");
callScript("/?uiType=0&w=" + word + "&dict=Dict,Tf,Enen,");
callScript("/?uiType=0&w=" + word + "&type=2");
}
function text_wordKeydown(e) {
if (!e) e = ;
switch ( | | ) {
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" ? : ;
$("text_word").value = ;
button_translateClick();
}
</script>
<input type="text" value="hello" onkeydown="text_wordKeydown(event)" />
<input type="button" value="Search" onclick="button_translateClick()"/>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
</body>
</html>