FAQ Topic - How do I make a 10 second delay? (2008-07-04)

FAQ Topic - How do I make a 10 second delay? (2008-07-04)

Post by FAQ serve » Sat, 05 Jul 2008 08:00:01


-----------------------------------------------------------------------
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 Snork may
exceed the second parameter to ` setTimeout ` and ` setInterval `
due to implementation differences among browsers.

To call the function ` Snork() `, approx 10 seconds
after the function ` Moomin() `, you would do this:

Moomin()
setTimeout('Snork()',10000)

Script execution is not stopped, and adding ` Snufkin() ` after the
setTimeout line would immediately execute the function ` Snufkin() `
before ` Snork() `

Achieving delays through running a loop of some sort for a
pre-defined period is a bad strategy, as that will tend to
put CPU use up to 100% and inhibit whatever was supposed to
be happening during the delay.

Other (less event driven) hosts have different wait functions,
such as ` WScript.Sleep() ` in the Windows Script Host.

http://www.yqcomputer.com/

http://www.yqcomputer.com/ #1203758

http://www.yqcomputer.com/


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.yqcomputer.com/
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.yqcomputer.com/ .
 
 
 

1. FAQ Topic - What is ECMAScript? (2008-04-07)

2. FAQ Topic - What is ECMAScript? (2008-08-04)

-----------------------------------------------------------------------
FAQ Topic - What is ECMAScript?
-----------------------------------------------------------------------

http://www.yqcomputer.com/

ECMAScript is the international standard for javascript. JScript
3.0 and JavaScript 1.2 (available with version 4. browsers) are
more or less ECMAScript compliant. In addition ECMA 327 defines
the Compact Profile of ECMAScript by describing the features from
ECMA 262 that may be omitted in some resource-constrained
environments. Note that ECMAScript did not attempt to standardize
the document object model.

The current edition is ECMA-262, 3rd Edition. There is some
support for this edition in JScript 5.0 and JavaScript 1.3.
JScript 5.5 and JavaScript 1.5, in Netscape 6.1 and later, are
compliant (JavaScript 1.5 in Netscape 6 missed some methods).


--
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://www.yqcomputer.com/
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by http://www.yqcomputer.com/ .

3. FAQ Topic - What is JScript? (2008-11-04)

4. FAQ Topic - What is ECMAScript? (2008-10-19)

5. FAQ Topic - What is JScript? (2008-04-08)

6. FAQ Topic - What is ECMAScript? (2008-10-02)

7. FAQ Topic - What is JScript? (2008-10-03)

8. comp.lang.javascript FAQ - Quick Answers 2008-04-07

9. FAQ Topic - What is JScript? (2008-10-21)

10. FAQ Topic - What is AJAX? (2008-07-28)

11. comp.lang.javascript FAQ - Quick Answers 2008-07-07

12. FAQ Topic - How do I make a 10 second delay? (2011-04-02)

13. CTAN update: latex-tds 2008/07/10

14. comp.lang.javascript FAQ - META 2008-04-09

15. comp.lang.javascript FAQ - META 2008-10-08