View Full Version : trigger when innerHTML/innerText done
frontline
12-30-2002, 09:21 AM
hello
is there any way to know when document.all["foo"].innerHTML="....some long string.....";
is done its operation ?
basically what im trying to do is make somekind of <div>loading.....</div>
and beneath it to place hidden <div> that will get the innerHTML string and after it done innerHTML'ing it will hide the "loading" div
and show the previous hidden div,
any ideas?
thanks
Algorithm
12-30-2002, 12:01 PM
I've found that in most browsers, unless you trick the system into thinking it's done running code, it won't update the display. This means that it's quite simple to do what you're asking by employing timeouts, as follows:// This code assumes functions displayLoadingDiv(), hideLoadingDiv(),
// and setFooInnerHTML() are predefined.
function fillFoo(){
displayLoadingDiv();
setTimeout('fillFoo2()',1);
}
function fillFoo2(){
setFooInnerHTML();
hideLoadingDiv();
}
yes, ideas... ;-)
the div you want to load the text into, set its style invisible.
Then you insert an onload-event in this div to make it visible.
If this doesn't work - could be, i don't now if the onload-event is supportet in divs - make it invisible anyway and add a javascript line at the end of the string you want to load into the div making the div visible.
brothercake
12-30-2002, 06:14 PM
Just a side note - you shouldn't really be using the document.all collection - iterating through it is incredibly inefficient; document.getElementById is much better, and not proprietary.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.