<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial>>> I seem to remember that in the past we have
talked about the order that JS<BR>>> actually processes its commands, and
the results are not always what you<BR>>> might
expect.<BR>>><BR>>> I've just come across that now, and can't work
out a way to fix it. I have a<BR>>> very slow routine that takes about 5
seconds to process even on a P4 2.4Ghz<BR>>> machine. My idea was to have
a 'loading - please wait' gif who's visibility<BR>>> is initially set
to 'hidden'. At the crucial point, I would make the gif<BR>>> visible, do
the routine, then make the gif 'hidden' once more.<BR>>><BR>>>
However, when I initiate this process by clicking on a button, the
gif<BR>>> doesn't display at all. Hmm - why would that be? Removing the
'make the gif<BR>>> hidden once again' code reveals that when the button
is clicked, the gif is<BR>>> not made visible until the slow routine has
completed, which means there's<BR>>> no point in doing it! This occurs
even though the code is<BR>>><BR>>> show_the_gif();<BR>>>
slow_routine();<BR>>> hide_the_gif();<BR>>><BR>>> Any thoughts
?</FONT></DIV>
<DIV><FONT face=Arial><BR> </DIV></FONT>
<DIV><FONT face=Arial color=#000080>From: "Peter-Paul Koch" <</FONT><A
href="mailto:pp.koch@gmail.com"><FONT face=Arial
color=#000080>pp.koch@gmail.com</FONT></A><FONT face=Arial><FONT
color=#000080>><BR>> Most browsers (except Opera) change the visible
display of the page<BR>> only when all scripts have exited completely.
Solution: use a timeout:<BR><BR>function show()<BR>{<BR> gif.src =
'pleasewait.gif'; // or whatever<BR>
setTimeout('slow_routine()',10);<BR>}<BR><BR>> Now the script exits after the
gif has been set and the browsers show<BR>> it. Then the slow routine kicks
in. Result: user sees Please Wait.<BR></FONT><BR></FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Hi - I got it working after a bit of experimentation. I
found that it would only work properly if I placed a timeout around the slow
routine *and* the hide routine.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT
face=Arial>showGif('icon_5');<BR>setTimeout("slowRoutine()",10);<BR>setTimeout("hideGif('icon_5')",10);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>One strange thing happens, though. My gif is an animated
gif: <IMG alt="" hspace=0 src="cid:001401c5c27d$06c80700$0100a8c0@ic7g"
align=baseline border=0> showing the word 'loading' and a moving bar. However,
when it is displayed as described above, the animation does not happen - it just
stays still. I can live with that, though.</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Thanks,</FONT></DIV>
<DIV><FONT face=Arial>Tim in Ireland</FONT></DIV></BODY></HTML>