setTimeout()的用法

 循环执行
var timeid = window.setInterval(“方法名或方法”,“延时”);window.clearInterval(timeid); 


定时执行:
var tmid = window.setTimeout(“方法名或方法”, “延时”);window.clearTimeout(tmid); 


setTimeout()的用法

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title>setTimeout()的用法 </title>
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-store">  
  <meta http-equiv="expires" content="0">    
  <meta http-equiv="Content-Type" content="text/html;charset=GBK">
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>

 <body>

  <script language="JavaScript">
//setTimeout()的用法

function showTime(){
    var today = new Date();
    alert("The time is: " + today.toString());
}

//调用方法一
setTimeout(showTime, 500);

//调用方法二
setTimeout("showTime()", 500);

//匿名示例一
setTimeout(function(){
        var today = new Date();
        alert("The time is: " + today.toString());
    }, 500);

//匿名示例二
setTimeout("alert('對不起, 要你久候')",3000)
  </script>



 </body>
</html>


 

你可能感兴趣的:(html,Date,XHTML,function,generator)