Reputation: 3205
I have a HTML page which is divided into two frames. Separate web sites are being opened by users in those frames as I provided an open web site option.
These web sites can be in any language. So. i need to translate the languages of these websites to English.
I am using JQuery translate function for this which is not working. As I am new to JQuery, I may be using incorrect syntax / way.
I have tried this code in Firefox, which is not working. I have tried in Chrome, but I am not able to know that it is working or not because of the default language translate option of the Google Chrome. I have also searched StackOverFlow Questions, but I didn't find anything.
$(function(){ //on document ready
$('body').translate('en');
})
Here is a link to the plugin: http://code.google.com/p/jquery-translate/wiki/TranslateMethod
Upvotes: 2
Views: 1342
Reputation: 6239
First of all, the jQuery library and the script should be called from one of the frames, not the container page, otherwise it won't work.
The jQuery function jQuery()
(or $()
) looks by default in the current document. In order to apply that function to a frame you should specify the context as a second argument of the function. In this case it would be like:
$(function() {
$('body', window.parent.frames[0].document).translate('en');
});
You can obviously change the index of the array frames
(frames[0]
, frames[1]
, ecc..) to match the frame that you want to translate.
edit: you can also set a name to the frame (putting the attribute name
in the tag <frame>
and then call it using window.frame_name.document
.
Upvotes: 1