Current course:



A "timeout" is like setting a kitchen timer and telling it to do something specific when it's time runs out.

The Code:

      <script type="text/javascript">
            function delayedAlert() {
                  setTimeout('alert("TESTING")', 3000);

      <a href="#" onmouseup="delayedAlert();">Delayed Alert on Mouse Up (click)</a>


Delayed Alert on Mouse Up (click)


The mouseup event calls the "delayedAlert" function and this starts the javascript timeout with "setTimeout", and passes two variables - the first is what you'd like to run, and the second is time (in milliseconds) before it should run.

In this case, we have it call an alert (with "TESTING" as it's alert text), and we tell it to wait 3 seconds (3000 milliseconds) before it calls it.