-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
  • 123,204
  • 21
  • 253
  • 243
George
  • 2,371
  • 4
  • 13
  • 15