Pause execution in JavaScript

By: Dave Reed Emailed: 1643 times Printed: 2112 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

This javascript pauses the execution for specifed numSeconds.
function pause(numSeconds)
// Assumes: numSeconds >= 0
// Results: pauses execution for numSeconds seconds
{
    var now, goalTime;

    now = new Date();
    goalTime = now.getTime() + 1000*numSeconds;

    while (now.getTime() < goalTime) {
        now = new Date();
    }
}

  

Javascript Home | All Javascript Tutorials | Latest Javascript Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Dave Reed
Pause execution in JavaScript
Verifying user input in JavaScript

More Tutorials in Javascript
Use WinSCP to transfer log files remotely using Javascript
Verifying user input in JavaScript
Pause execution in JavaScript
Javascript to display client date and time on webpage
Getting Browser's height and width using Javascript
Highlighting text on a page using CSS
Using revealTrans to do page transitions in Javascript
Password protect a web page using Javascript
Diabling Right Click option in a browser using Javascript
Scrolling message on the status bar using Javascript
window.frames[i] in Javascript
Form validation using Javascript
Using && in Javascript
The if statement in Javascript
do-while, while, for and for-in loops in Javascript

More Latest News
Most Viewed Articles (in Javascript )
Using parseInt() and parseFloat() in JavaScript to convert data types to Numbers
Typecasting in Javascript
Pause execution in JavaScript
Show how many characters remaining in a html text box using javascript
List of Keywords and reverved words in Javascript
Using toString() in JavaScript to convert data types to String
Bitwise NOT, AND, OR, XOR operators in Javascript
Click to remove an element from a select html form using javascript
History and evolution of Javascript
Javascript Basics
Using ! and !! in Javascript
Using && in Javascript
The if statement in Javascript
do-while, while, for and for-in loops in Javascript
break and continue in Javascript
Most Emailed Articles (in Javascript)
Click to remove an element from a select html form using javascript
this keyword sample in Javascript
Diabling Right Click option in a browser using Javascript
Use WinSCP to transfer log files remotely using Javascript
History and evolution of Javascript
Bitwise NOT, AND, OR, XOR operators in Javascript
Using ! and !! in Javascript
Getting Browser's height and width using Javascript
Javascript to display client date and time on webpage
Verifying user input in JavaScript
Show how many characters remaining in a html text box using javascript
Using toString() in JavaScript to convert data types to String
Using parseInt() and parseFloat() in JavaScript to convert data types to Numbers
Using && in Javascript
Highlighting text on a page using CSS