balazs-endresz / jquery-translate

Automatically exported from code.google.com/p/jquery-translate
5 stars 5 forks source link

Translate doesn't work in IE6/IE7 when the page is inside an iframe #31

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I use jquery-translate to translate webpages inside an iframe. It works
fine with IE8, FF, Chrome and Safari. 

However it doesn't work in IE6/I7, there is a problem here:

764. e.html( newElem.contents() );

You can replicate the problem easily, just create a html page with an
iframe inside and try to translate the content using IE6/IE7

Any idea about how to fix that error?

Thanks!

Original issue reported on code.google.com by frank...@gmail.com on 14 Mar 2010 at 1:09

GoogleCodeExporter commented 9 years ago
Interesting, I'll look  into it. Until it's fixed you can avoid this issue by 
setting the 
`rebind` option to false, or by using $(..).translateTextNodes() instead of 
$(..).translate().

Original comment by balazs.endresz on 14 Mar 2010 at 9:17

GoogleCodeExporter commented 9 years ago
What error did you get exactly? For me there's an error at the end of the 
jQuery.clean 
function.

Original comment by balazs.endresz on 14 Mar 2010 at 11:10

GoogleCodeExporter commented 9 years ago
You have to replace this line

var origContents = e.find("*").not("script"), newElem = $("<div/>").html(t);

with the following:

function getDoc(node){
    while (node && node.nodeType!= 9)
        node = node.parentNode;
    return node;
}
var doc = getDoc(e[0]);
var origContents = e.find("*").not("script"), newElem = 
$(doc.createElement("div")).html(t);

Please let me know if there are still some issues with this!

Original comment by balazs.endresz on 14 Mar 2010 at 12:19

GoogleCodeExporter commented 9 years ago
Hi!

Thanks for your quick reply. I replaced the line with your code but IE6/I7 
still give
an error...

however, setting the rebind option to "False" then the problem disappears...so 
I will
place a conditional in the code to detect Ie6/IE7 browsers and set "rebind" on 
the fly

Thanks!

Original comment by frank...@gmail.com on 15 Mar 2010 at 5:53

GoogleCodeExporter commented 9 years ago
Could you please post the html in the iframe? If it's not public you can send 
it by 
email as well (my username + gmail.com). Thanks!

Original comment by balazs.endresz on 15 Mar 2010 at 6:29

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
In 1.4.6 I included the above fix, and it seem to work for me. The only 
difference is 
that the ownerDocument is detected only once, so you cant translate multiple 
iframes in 
one call.

Original comment by balazs.endresz on 27 Mar 2010 at 2:37