JRS: In article <9b********************************@4ax.com>, seen in
news:comp.lang.javascript, Mool <Th*********@TheVillage.Net> posted at
Sat, 10 Jul 2004 07:24:22 :
I want to use a setTimeout to just loop for a number of seconds, then
fall through to the next bit of code...can this be done by using some
kind of null in the statement, or do I have to assign the code a name
and call it from the setTimeout once it's done?
You are asking for setTimeout to cause a delay in the current line of
execution (you don't give a location, so I suppose we can rely on your
words meaning what you intend). That was OK in single-process systems
such as ran in plain DOS, but not appropriate in typical GUI
environments.
You should arrange for the initial line of execution to call
setTimeout() and then to terminate naturally. The later code is
provided as the first parameter of setTimeout(); AIUI it can be
anything, but it should be a short string. In this case, a function
call invoking the rest of the code is appropriate.
Basically, a total redesign that changes very little.
This is about the shortest possible example ( -88 in USA, -887 in EU ? )
<input type=button onClick="setTimeout('alert(999)', 1000)">
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> JL / RC : FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.