Google翻译元素-页面准备好后加载 [英] Google translate element - load after page ready

查看:109
本文介绍了Google翻译元素-页面准备好后加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上使用的是google网络翻译元素.对于那些不知道它是什么的人,可以在这里找到它: http://translate.google.com/translate_tools

I am using the google web translate element on my page. For those that don't know what it is you can find it here: http://translate.google.com/translate_tools

它使用javascript加载到页面上.我将其嵌入到页面的顶部,这导致我的其余内容停止加载,直到翻译栏完成加载为止.

It loads on the page using javascript. I have it embedded on the top of my page which causes the rest of my content to stop loading until the translate bar has completed it's load.

如何在我的页面完全加载之前延迟javascript的运行?

How can I delay the javascript running until my page has fully loaded??

这是脚本:

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    pageLanguage: 'en',
    includedLanguages: 'da,nl,en,fi,fr,it,no,ru,es,sv',
    layout: google.translate.TranslateElement.InlineLayout.SIMPLE
  }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

推荐答案

正如约翰·孔德(John Conde)所评论的,我将脚本放在页面底部,然后请记住,页面加载

As commented by John Conde, I put the script at the bottom of the page and hey presto, page load

这篇关于Google翻译元素-页面准备好后加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆