|
|
FAQ Topic - How do I make a 10 second delay? (2010-08-25)
-----------------------------------------------------------------------
FAQ Topic - How do I make a 10 second delay?
-----------------------------------------------------------------------
There is no built-in way to pause execution in javascript such
as a sleep function, but hosts usually provide a method of some
form. Web browsers are designed for event driven programming and
only provide the `setTimeout` and `setInterval` functions
to facilitate timed delays. The delay before calling `getSnork` may
exceed the second parameter to `setTimeout` and `setInterval`
due to implementation differences among browsers.
To call the function `getSnork`, approximately 10 seconds
after the function `getMoomin()` completes, you would do this:
getMoomin();
setTimeout(getSnork, 10000);
Script execution is not stopped, and adding `getSnufkin()` after the
`setTimeout` line would immediately execute the function `getSnufkin`
before `getSnork`.
Achieving delays through running a loop of some sort for a pre-defined
period is a bad strategy, as that will inhibit whatever was supposed to
be happening during the delay, including blocking user interation.
Other (less event driven) hosts have different wait functions,
such as `WScript.Sleep()` in the Windows Script Host.
<URL: http://msdn.microsoft.com/en-us/library/ms536753%28VS.85%29.aspx>
<URL: http://docs.sun.com/source/816-6408-10/window.htm#1203758>
<URL: http://en.wikipedia.org/wiki/Event-driven_programming>
<URL: http://jibbering.com/faq/faq_notes/misc.html#mtSetTI>
The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/
--
The sendings of these daily posts are proficiently hosted
by http://www.pair.com.
|
|
0
|
|
|
|
Reply
|
javascript4 (1180)
|
8/24/2010 11:00:02 PM |
|
|
0 Replies
173 Views
(page loaded in 0.017 seconds)
Similiar Articles: How to remove all subdirectory/file under current directory ...On Mon, 08 Mar 2010 23:06:54 -0800, moonhkt wrote ... somehow gives me just that fraction of a second to ... On Wed, 10 Mar 2010 06:53:25 -0800, moonhkt wrote: >> I ... WTB: EPROM Emulator for 2716 - comp.arch.embeddedOn Thu, 30 Sep 2010 19:46:10 -0700 (PDT ... nospam21 (7357) 10/1/2010 7:08:34 AM ... TI part, I think I remember the 25 instead of the 27 though. Of course I do ... How to get envelope from AM signal without phase shift - comp.dsp ...Reply: Jerry: 3/8/2010 2:25:58 PM ... say it can not be "phase shifted", do you include a simple time delay ... modulation Your choice of terms do not make ... problem in interface - comp.lang.fortranOn 2010-05-25 14:28:52 -0300, rudra <bnrj.rudra@gmail.com ... 3D=3DTHIS MUCH SHOULD BE IN FIRST ROUTINE AND SECOND ... 5/27/2010 3:59:08 AM Use of MATLAB fftshift - comp.dspSecond, that the fft() implements a particular DFT ... Jun 25, 2010 11:27:45 AM, chris.bore@gmail.com wrote ... 7/4/2010 4:42:08 PM Wargame of the Year 2009 - Election - comp.sys.ibm.pc.games.war ...On topic: My vote for #1 goes to WitP:AE ... strategically, the Germans managed to do this without too much delay. ... On 08/01/2010 10:25, eddysterckx@hotmail.com wrote ... file opening slows down - puzzling - comp.lang.xharbourReply: D: 1/15/2010 10:53:08 AM ... trivial one, the well-known delay in ... file 1,2 Mb + 2 indexes 64 Kb and 25 Kb: 0,08 opens 2 more files quite small: 0,10 ... Timekeeping broken on Windows XP with multimedia timer enabled (-M ...... time drifiting backwards by up to a second ... 1/25/2010 9:35:08 AM ... www.plugcomputer.org/plugwiki/index.php/Frequently_Asked_Questions ... top 10 uses for random data compression?? anyone? - comp ...On Wed, 08 Dec 2004 19:44:06 +0000, Mathew Hendry ... 12/11/2004 6:34:25 PM ... I was hiring to present you some of my left topics. Neatest way to get the end pointer? - comp.lang.cOn Feb 6, 2:08 am, Keith Thompson <ks...@mib.org> wrote ... in the answer to question 6.17 in the comp.lang.c FAQ ... On Feb 6, 4:25=A0pm, Ben Pfaff <b...@cs.stanford.edu ... comp.lang.javascript FAQcomp.lang.javascript FAQ. Version 32.2, Updated 2010-10-08, by Garrett ... include Safari 2 and Opera <= 9.25 ... 10.8 How do I make a 10 second delay? There is no built-in way ... FAQ - MATLAB WikiThis is a list of frequently asked questions (with ... 6 13 20 22 10 12 19 21 3 11 18 25 2 ... WARNING: as of Nov. 10, 2010 that link ... 7/26/2012 2:45:27 PM
|
|
|
|
|
|
|
|
|