From: Hans-Georg Michna on
On Fri, 1 Jan 2010 12:15:04 -0800 (PST), David Mark wrote:

>On Jan 1, 3:04�pm, Hans-Georg Michna <hans-
>georgNoEmailPle...(a)michna.com> wrote:

>> I fear that we currently don't have any reliable way at all to
>> determine when a dynamic change has been completely rendered to
>> screen, as the window.onload and the document.onreadystatechange
>> events probably don't fire again after a dynamic change. I guess
>> they fire only during the initial loading of the page. Can
>> anybody confirm or deny this?

>Yes. Denied.

Ah, I should have tested. Anyway, thanks for saving me the work.

So you are saying that, when JavaScript code makes a change to
the DOM, the document.readyState changes back from "complete" to
"interactive", then again to "complete"?

>> Has anybody here done any experiments in this regard? Like
>> dynamically appending a one-pixel-high element at the bottom of
>> the page and then checking if or when the total page height
>> increases by 1 pixel? There is always some work to do. (:-)

>The height changes immediately (i.e. DOM properties reflect the
>addition). The change to the layout happens some time after (usually
>on exiting an execution context). Again, what is it you are trying to
>do?

Interesting that the DOM already "knows" the height, before it
is actually rendered to screen. I guess that is what you meant.
It could also mean that we have no way to tell when the screen
rendering is complete. Is that so?

My original intention was merely to let some JavaScript code be
able to read the entire DOM and make changes to it as early as
possible. The bad solution would be to wait until all auxiliary
files, like images, are loaded. I was hoping that
document.readyState === "complete" would help me there. But
apparently that is not the case, or not much, anyway.

My second intention is to learn. I'm still somewhat new to
JavaScript, but find it both useful and quite interesting.

Hans-Georg