![]() |
Developing a triple iframe rolling refresh, inc. on change of state
3 iframes in a container page.
It should be simple to refresh iframe2 from iframe1 etc. I've spent hours on this........ I must be doing something stupidly wrong. :( None of my reload scripts will fire. Here is the containing page: Code:
<body><div id="container1">The css provides me with full size iframes: Code:
#container1 {Code:
function reload_page_2()Can anybody see what I'm doing wrong? |
Quote:
|
Quote:
I didn't even know it existed. Thank you for that response. :thumbsup: |
I fixed the loading problem (I was missing .window):
Below are the scripts that should enable:
BTW it doesn't fully work, as I believe the delay is not truly a delay to the script: Code:
function store_pg_1()At the moment the storage of pg_2_text is prior to translation. (I can confirm this with an onClick to reload iframe3, which then retreives the translation). Progress though. :) |
To get around the the need to pause the script until the translation is complete I tried the code below, but it was a fail:
Code:
function reload_page_2()Maybe it starts to re-load, but maybe not. Google is just writing in the translation maybe. Does anybody have any ideas on how to pause the script until the translation is complete? |
it sounds like you would probably use a callback
|
Quote:
It seems that you need to understand (first) what is actually happening. In reality, I don't know what event is occurring & ending. Obviously I know that my text has been sent to google, and that it is returning (modified). Clearly a change of state is: triggered - not finished - finished. But worse than that.... the page first loads fully ie. one state complete; and then there is a pause while the text is sent to google (ie. the first state is still stable). Then the returned translated text is written in. If we know what the final state is, then we might compare it to the the 1st state - which is page loaded and original text written in (if any, cos iframe2 is originally empty, but it will gradually acquire text, as it is typed into iframe1). What we can be certain of, is that the 2nd completed state, is going to be different to the 1st completed state. Perhaps it's possible to monitor the sending to google of the original text. Ie. English arrives in iframe2. It is then sent, or called, to google. This 'data transmission' might then allow the 1st state to be logged. The 2nd state (different) could be compared to the 1st, but can we determine, when the return text has fully arrived? I think once we understand how javascript can recognise these events, then the appropriate function can be fired. Does anybody understand these events? |
Quote:
|
Quote:
Code:
#googtrans(en|fr)
Code:
<iframe name="iframe2" src="iframe_2.html#googtrans(en|fr)">Code:
<meta name="google-translate-customization" content="f3ec1860041f93e1-f800c17a206199a4-g305246f186c2820d-15">The above is part one of two sections of code.3. The Body code (on page requiring translation - iframe2) Code:
<div id="google_translate_element"></div>The Links: http://translate.google.com/ Then click the link http://www.google.com/url?source=tra...ite/%3Fhl%3Den I'm gonna look for the chrome console log, as it is jam packed with info on what is going on. |
I have run chrome with logging enabled.
To keep the log pure to the task, I set the launch page to http://www.max-haut-debit.fr/transla...ator_page.html I had already blanked the local storage cache for iframe2 & iframe3 by passing the empty textarea thru localstorage to iframe2 which passed it on to iframe3 As a result, this is what the log shows (I deleted the old logs):Step 1 Therefore as chrome loaded: iframe2 & 3 loaded, and their scripts fired with almost no data. Step 2 I pasted some english text using ctr+v into textarea. onClicked the text. The text was localstored iframe2 reloaded, retrieving the text, and displaying it in english. The text was then sent to google. It was returned in French, and displayed. Step 3 Step 3 already started probably milliseconds after onclicking the text. iframe3 had reloaded retrieving the blank local storage. This is the problem area, pausing the rolling reload, until translate has done its bizStep 4 I onclicked iframe2, causing the translated text to go to localstorage. iframe3 reloaded, retrieving the French text. The text was sent to google. It was returned in English, and displayed. Step 5 I quit chrome, and copied the log to temp. I copied the log to pastebin. This log should only contain the tasks described above: http://pastebin.com/016QNsSz |
I am wondering about the need for local storage here, which has growing support but not below IE8. Also your interface is a little unintuitive - you can pass the value of the textarea to the iframe onkeyup and do it that way. Here's one way, anyway. Main page:
Code:
<html>Code:
<html> |
Quote:
I used onclick purely so that I could control events. The system is primarily set up as a test bed for the scripting. My idea was ultimately to use the 'Enter' key, to act on the finalisation of a paragraph: Type a paragraph - have a look (how did it turn out) continue, or have another go. Onkeyup may be more akin to the google translate page, where characters are sent individually, building a paragraph that is ultimately translated. But either way, the thinking was that, the final processes would inform the final design. Re your suggested code..... it looks like you have discerned the key commands. :) I was working with what was auto-available (from ignorance of the detail). This enlightenment, means I need to spend a bit more time understanding what is happening - but at least I know now, where to look. :) The log file has proved definitely to be good educational material, even for the uninitiated (who are prepared to go thru each line a couple of times). Thanks very much for your interest in this project. :) . |
yes. there is a problem though - there doesn't seem to be a way to auto select the language - and therefore have an automatic translation - on first page load (if you have done this already you would have to clear your cache to see what I am talking about). You would think that the autoDisplay parameter might do something, but from what I can tell setting it to true, false or even removing it completely seems to have no effect at all :confused:
|
The good news is that the system now only requires the removal of one "onClick" event handler.
more on that later. Quote:
Code:
<iframe name="theframe" width="500" src="translated.html#googtrans(en|fr)"> </iframe>With this added & using google chrome, I have seen no problems. I cleared the cache, but the scripts & display functioned as expected. For no other reason that this, I believe the anchor link must solve this problem. Quote:
Once translated, it must be displayed. Based upon an understandable philosophy that is effectively: "Be aware, this data has been modified". Therefore the question is only whether it is always displayed, when say a French browser, visits English pages. As we are translating, it will always display. |
ah, I get it now. thanks for explaining.
can I ask what the purpose of the other iframe is? it seems to want to translate to English? But if the input language is English what is the idea? and why not fire the function on the onkeyup of the textarea the way you do with the first iframe? also, this is going to cause you problems: Code:
<body onhaschange="translateIt(document.body.innerText)">innerText will get you into trouble, too. innerText is IE only. textContent is more widely accepted, but IE only started recognising it at IE9+ if you are only looking to translate the text from the textarea, it is much easier just to be getting the value of that textarea, the same as you are doing now. |
| All times are GMT +1. The time now is 05:28 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.