JavaScript Reference/Javascript Methods/setTimeout

Материал из Web эксперт
Перейти к: навигация, поиск

"setTimeout()" Example

   <source lang="javascript">
   

<html> <body> <script language="javascript">

   var intValue = 0
   function myMethod(){
       alert("Hello");
   }

</script> <button onclick="intValue=window.setTimeout("myMethod()", 1000);">Start timeout</button> <button onclick="intValue=window.clearTimeout(intValue);">Stop timeout</button> </body> </html>


     </source>
   
  


"setTimeout()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |window | +----------------+--------------------------------------------------------------+

     </source>
   
  


"setTimeout()" Syntax, Parameters and Note

   <source lang="javascript">

Note: Set the timer and cancel it by the clearTimeout().

Syntax:

window.setTimeout(param1, param2, param3) Parameters:

   param1   Required; a function name or string of code that will execute when the timeout has elapsed.
   param2   Required; the length of the timeout in milliseconds.
   param3   Optional; param1"s script language. 
                      JScript, 
                      vbscript, 
                      vbs, 
                      javascript, 
                      XML.
   
     
     </source>