Google Translate iframe workaround

戏子无情 提交于 2019-11-28 07:01:00

问题


I'm using Google Translate tools to translate a web page and I also have an iframe on this page, that is not obviously translated with the page.

Is there a workaround, that any of you know, so I can have the iframe translated as well?


回答1:


This is a genuine limitation or policy of Google Translate. You can't rewrite iframe content. But one thing you can do is change iframe url to translated page like:

<iframe height="1200" width="600" src="http://translate.google.com/translate?hl=bg&ie=UTF-8&u=YOUR_IFRAME_URL&sl=de&tl=bg" align="middle" border="0">



回答2:


If you need to translate the page with iframes, you can:

1. Use Bing Translator, that proxyfies request, so it wouldn't be cross domain.

site:

https://www.bing.com/translator

plugin that uses it (not tested):

https://chrome.google.com/webstore/detail/translator/blndkmebkmenignoajhoemebccmmfjib

2. You can run your browser (if it's Chrome) with --disable-web-security param, so it would allow access to frames from other domains.

Please note that it's dangerous and should only be used on trusted sites.




回答3:


  1. Create empty iframe.
  2. Ajax the second iframe content already translated by google translator.
  3. Dump the response of the ajax into empty iframe.

$("#id_of_empty_iframe").load("http://translate.google.com/translate?hl=bg&ie=UTF-8&u=YOUR_IFRAME_URL&sl=de&tl=bg");



来源:https://stackoverflow.com/questions/22936421/google-translate-iframe-workaround

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!