Document.write and pausing
Hello everyone,
I'm playing around with document.write (just for the fun of it). My question is about the following code.
Code:
<iframe src="some_file.html" name="probe" onload="external_html=frames.probe.document.body.innerHTML"></iframe>
<script>
alert();document.write(external_html)
</script>
The alert pauses parsing until we click on OK. During that brief moment of time, the iframe will have loaded, implying that external_html is 'known' after the click on OK. The result is a page that does not only contain the iframe, but also the innerHTML of the iframe (outside of it). And since we used document.write, every bit of code written in the iframed page will be automatically tranferred to the containing page (and will execute!).
If we leave out the alert, document.write will achieve nothing, because external_html is not known yet at the time document.write is called. A timer won't correct this in a proper manner, because the whole page would be rewritten (and the iframe would not be visible anymore; this also applies to all other content).
In other words, a timeout is not a good replacement of the alert. I tried a javascript sleep function: no result either. So my question: is there some piece of code that does exactly what the alert does except for the appearance of the alert box?
Note: I'm not interested in solutions that use Ajax / that don't use the native document.write.
Thanks.