Question:

How do I create a a timeout in javascript?

by  |  earlier

0 LIKES UnLike

How do I create a a timeout in javascript

 Tags:

   Report

2 ANSWERS


  1. Need to clarify usage of the term "timeout."

    If you want to launch a process after some interval of delay, the function  setTimeout() exists. Documentation of setTimeout() (and related functions) can be retrieved from:

    http://www.elated.com/articles/javascrip...

    If you want to pause processing temporarily, there's no native delay/pause method. If you need a pause() function that makes a program wait for an interval before moving to the next step, I've implemented one based on the busy-wait anti-pattern. I recommend it ONLY if you can think of no OTHER way to code your solution to timing. The DelayManager prototype that discloses the public pause() function can be found at:

    http://home.comcast.net/~richarduie/samp...


  2. It would be something like this:

    <script type="text/javascript">

    setTimeout("alert('Thirty seconds has passed.');",30000);

    </script>

    The first parameter is what is going to be executed, it can be an alert or any function, the second parameter is the delay in miliseconds.

    Hope it helps

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions