-6

How i can start function after a time , for exampl e:

<script>
function alert()
{

alert("Execute alert after 5 seconds");

}
</script>


alert();

I need inside function tell execute after 5 seconds , how i can do this , i need this control inside function no in other function or external , inside of alert function the control for launch the function after 5 seconds for example

After this time the function must be execute finally

Thank´s Regards

1 Answers1

2

Use JavaScript's setTimeout function.

e.g.

setTimeout(function(){ alert("Hello World!"); }, 5000)

(The parameters are function and milliseconds before it executes)

PSL
  • 122,084
  • 19
  • 250
  • 241
George
  • 2,181
  • 4
  • 12
  • 15