我插入了一段代码,我发现它可以放置由谷歌翻译支持的标记小部件,以便能够拥有更多语言的网站。虽然确实出现了标志,并且光标似乎将其识别为链接,但在 Chrome 上测试它(没有上传)时,我单击了标志,但没有任何反应。
我是否需要上传它才能正常工作,或者这是代码中的问题吗?
抱歉,如果这是一个愚蠢的问题,我对这一切都很陌生:)
代码:
`<script language="JavaScript"> <!--
document.write ("<input name=u value="+location.href+" type=hidden>")
// -->
</script>
<input name="hl" value="es" type="hidden">
<input name="ie" value="UTF8" type="hidden">
<input name="langpair" value="" type="hidden">
<input name="langpair" value="es|en" title="English" src="images/UK.gif" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30">
<input name="langpair" value="es|pt" title="Portuguese" src= "http://photos1.blogger.com/img/43/1633/320/13539966_0d09b410b5.jpg" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30">
<input name="langpair" value="es|fr" title="French" src= "http://photos1.blogger.com/img/43/1633/320/13539949_e76af75976.jpg" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30">
<input name="langpair" value="es|de" title="German" src= "http://photos1.blogger.com/img/43/1633/320/13539933_041ca1eda2.jpg" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30">
<input name="langpair" value="es|it" title="Italian" src= "http://photos1.blogger.com/img/43/1633/320/13539953_0384ccecf9.jpg" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30">
<input name="langpair2" value="es|ar" title="Arabic" src= "http://photos1.blogger.com/blogger/3709/485/1600/arabic-flag.gif" onclick="this.form.langpair.value=this.value" height="20" type="image" width="30" />
</form>`
最佳答案
首先,您缺少 <script ...
之前的开放表单标签:
<form action="http://www.google.com/translate" >
我从本地文件进行了测试,按下标志会将您发送到 translate.google.com
.
但是,Google 必须访问您的 HTML 页面才能对其进行翻译,因此此小部件仅在 Internet 上的公共(public)网站上起作用。它似乎不适用于本地或 Intranet 站点。
关于javascript - 谷歌翻译 html 小部件不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38637659/