我有一个简单的必应翻译示例,但它不适用于谷歌浏览器。
我不明白是 bing 问题还是我的代码错误。
这是我的示例的代码
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function translate() {
document.getElementById('trans').innerHTML="";
var text= document.getElementById('ori').value;
window.mycallback = function(response) {
document.getElementById('trans').innerHTML=response;
}
var languageFrom = document.getElementById("langpairFROM").value;
var languageTo = document.getElementById("langpairTO").value;
var s = document.createElement("script");
s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=mycallback&appId=68D088969D79A8B23AF8585CC83EBA2A05A97651&from=" + languageFrom + "&to=" + languageTo + "&text=" + text;
document.getElementsByTagName("head")[0].appendChild(s);
}
</script>
</head>
<body>
<center>
<select id="langpairFROM" STYLE=" font-size : 11pt">
<option value="de">German</option>
<option value="en">English</option>
<option value="ru">Russian</option>
</select>
<select id="langpairTO" STYLE=" font-size : 11pt">
<option value="ru">Russian</option>
<option value="de">German</option>
<option value="en">English</option>
</select>
<button type="input" onclick="translate()" >Translate</button>
<div >
<textarea id="ori" name="translate" ></textarea>
</div>
<div id="translationField">
<textarea id="trans" >Translated Text</textarea>
</div
</center>
</body>
</html>