开发者

googleTranslateElementInit not working with opera

<div id="google_translate_element" >

                  <script type="text/javascript">
                         function googleTranslateElementInit() {
                              new google.translate.TranslateElement({
                                  pageLanguage: 'en'
      开发者_JAVA技巧                              }, 'google_translate_element');
                                    }
                  </script>

        </div>

                 <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

This is my script to translate language. It works fine on all browsers except opera. What would be the problem? Any new suggesation to chnage language ?


Try this:

  1. Go to Google Translation > Tools and Resources (http://translate.google.com/translate_tools)
  2. Choose "Add translation to a section of the webpage" at Step 1
  3. Choose "English" as the language of your webpage at Step 2
  4. Click "Preview your page"
  5. In the generated page click "Translate everything to English"

source

Actually it is better with the callback function defined before it is used, as in your post.

One more thing, when you open translate.google.com opera's console states that it has modified some of the js. So the behavior on other domains might be different, e.g. not working at all, as in my case. :(


This never could work. Try to put script before everything else

    <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<div id="google_translate_element" >

                  <script type="text/javascript">
                         function googleTranslateElementInit() {
                              new google.translate.TranslateElement({
                                  pageLanguage: 'en'
                                    }, 'google_translate_element');
                                    }
                  </script>

        </div>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜