设定程序在某个特定时刻执行

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>run application</title>
 6 </head>
 7 <body>
 8 
 9 
10 <script type="text/javascript">
11 
12     //设定程序在某个特定时刻执行
13     var timeTask=setInterval(function(){
14         var date=new Date();
15 
16         var Y=date.getFullYear();
17         var M=date.getMonth()+1;
18         var d=date.getDate();
19         var h=date.getHours();
20         var m=date.getMinutes();
21         var s=date.getSeconds();
22 
23         //console.log("年:"+Y+"\t月:"+M+"\t日:"+d+"时:"+h+"\t分:"+m+"\t秒:"+s);
24         if(Y==2016&M==3&d==30&h==12&&m==0&&s==0){
25             callFunction();
26 
27         }
28     },1000);
29     function callFunction(){
30         alert(1);
31     }
32 
33 </script>
34 </body>
35 </html>

 

posted @ 2016-03-30 09:28  Window2016  阅读(265)  评论(0编辑  收藏  举报