-2

I have javascript for call 2 function for example:

system.library.myscript.function1();
system.library.myscript.function2();

I would like to set delay before run function2 for example 20 seconds. Highly appreciated for anything helps.

Pranav C Balan
  • 113,687
  • 23
  • 165
  • 188

1 Answers1

0

Use setTimeout() function:

setTimeout(function(){
 alert("Hello"); 
}, 3000);

:)

Victor Milazzo
  • 128
  • 2
  • 13
  • Don't use w3schools.com as a reference... Instead use the [Mozilla Developmer Network](https://developer.mozilla.org/en-us/docs/Web/API/WindowTimers/setTimeout) which also [explains the changing execution context (`this`)](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout#The_this_problem) which can be a problem here – Andreas Jun 01 '16 at 05:32
  • @Andreas—good comment re w3schools, but note that *this* is one parameter of an execution context, it's not **the** execution context (you can't get a reference to that). ;-) – RobG Jun 01 '16 at 05:45
  • @RobG You're right. I only added it because the section in the MDN article is labeled with " _The "this" problem_ " – Andreas Jun 01 '16 at 06:12