<!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>&gt;&gt; I seem to remember that in the past we have 
talked about the order that JS<BR>&gt;&gt; actually processes its commands, and 
the results are not always what you<BR>&gt;&gt; might 
expect.<BR>&gt;&gt;<BR>&gt;&gt; I've just come across that now, and can't work 
out a way to fix it. I have a<BR>&gt;&gt; very slow routine that takes about 5 
seconds to process even on a P4 2.4Ghz<BR>&gt;&gt; machine. My idea was to have 
a 'loading - please wait' gif who's visibility<BR>&gt;&gt;&nbsp;is initially set 
to 'hidden'. At the crucial point, I would make the gif<BR>&gt;&gt; visible, do 
the routine, then make the gif 'hidden' once more.<BR>&gt;&gt;<BR>&gt;&gt; 
However, when I initiate this process by clicking on a button, the 
gif<BR>&gt;&gt; doesn't display at all. Hmm - why would that be? Removing the 
'make the gif<BR>&gt;&gt; hidden once again' code reveals that when the button 
is clicked, the gif is<BR>&gt;&gt; not made visible until the slow routine has 
completed, which means there's<BR>&gt;&gt; no point in doing it! This occurs 
even though the code is<BR>&gt;&gt;<BR>&gt;&gt; show_the_gif();<BR>&gt;&gt; 
slow_routine();<BR>&gt;&gt; hide_the_gif();<BR>&gt;&gt;<BR>&gt;&gt; Any thoughts 
?</FONT></DIV>
<DIV><FONT face=Arial><BR>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial color=#000080>From: "Peter-Paul Koch" &lt;</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>&gt;<BR>&gt; Most browsers (except Opera) change the visible 
display of the page<BR>&gt; only when all scripts have exited completely. 
Solution: use a timeout:<BR><BR>function show()<BR>{<BR>&nbsp; gif.src = 
'pleasewait.gif'; // or whatever<BR>&nbsp; 
setTimeout('slow_routine()',10);<BR>}<BR><BR>&gt; Now the script exits after the 
gif has been set and the browsers show<BR>&gt; it. Then the slow routine kicks 
in. Result: user sees Please Wait.<BR></FONT><BR></FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial>One strange thing happens, though. My gif is an animated 
gif:&nbsp;<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>&nbsp;</DIV>
<DIV><FONT face=Arial>Thanks,</FONT></DIV>
<DIV><FONT face=Arial>Tim in Ireland</FONT></DIV></BODY></HTML>