我需要修改我的代码,以便自动翻译网页,甚至(如果可能的话)隐藏翻译按钮:
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'zh-CN', includedLanguages: 'bg', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false, multilanguagePage: true}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
这是我尝试过的:
<script type="text/javascript">
function Change() {
setTimeout(function() {
$(".goog-te-combo").val("bg").get(0).dispatchEvent(document.createEvent("HTMLEvents").initEvent("change", !0, !0))
}, 3000)
}
Change();
</script>
这是我得到的错误:
未捕获的TypeError:无法读取属性&#39; dispatchEvent&#39;未定义的