|
|
||
JavaScript Timing EventsIt's very easy to time events in JavaScript. The two key methods that are used are:
Note: The setTimeout() and clearTimeout() are both methods of the HTML DOM Window object. setTimeout()Syntax
The setTimeout() method returns a value - In the statement above, the value is stored in a variable called t. If you want to cancel this setTimeout(), you can refer to it using the variable name. The first parameter of setTimeout() is a string that contains a JavaScript statement. This statement could be a statement like "alert('5 seconds!')" or a call to a function, like "alertMsg()". The second parameter indicates how many milliseconds from now you want to execute the first parameter. Note: There are 1000 milliseconds in one second. clearTimeout()Syntax
|
||