我有这个代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("language", "1");
function initialize() {
$sents =$_GET["ftext"];
google.language.translate($sents, "en", "he", function(result) {
if (!result.error) {
var container = document.getElementById("translation");
container.innerHTML = result.translation;
}
});
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body>
<div id="translation"></div>
</body>
</html>
我有一个要翻译的变量(它的名称在 中ftext
)。我正在使用 GET 方法从其他网页捕获它,问题是我不知道如何捕获它并在初始化函数中使用它。我做错了什么?
这是我从中获取文本的网页:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>MY-Site</title>
</head>
<body>
<form method=get action=new1.html accept-charset=utf8>
<textarea name=ftext cols=12 rows=3 dir=ltr>
</textarea><br>
<input type=submit value=send>
</form>
</body>
</html>