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:
- Go to Google Translation > Tools and Resources (http://translate.google.com/translate_tools)
- Choose "Add translation to a section of the webpage" at Step 1
- Choose "English" as the language of your webpage at Step 2
- Click "Preview your page"
- 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>
精彩评论