///pc/img/blank.gif" width="12" height="8">当前位置:///default.htm" class="under">亿度网络 -> ///pc/index.htm" class="under">网页制作教程 -> JavaScript实例
///pc/homepage/javascript/sample/img/bule.gif" width="207" height="13"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/js.gif" width="186" height="20"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1"> ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">
     倒 计 时 ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
    ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  
效 果 演 示 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
 

 

 


 

 

   
 
源代码如下 ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">



这段程序放在<body>与</body>之间

 


   
源程序讲解: ///pc/homepage/javascript/sample/img/bule2.gif" width="11" height="18">
  ///pc/homepage/javascript/sample/img/bule1.gif" width="28" height="49">  

var deadline= new Date("7/30/2000");
定义“到期”变量。你可以随便设置。
var symbol="7月30日";
定义“日期性质”变量,可以随便设置。
var now = new Date();
设置“现在”的时间。
var leave =deadline.getTime() - now.getTime();
设置变量“leave”的值为到期时间减现在时间,返回的为毫秒数。
var day = Math.floor(leave / (1000 * 60 * 60 * 24));
;
将毫秒数化为天数,并返回一个不大于天数的整数。
if (day > 0)
document.write("今天离"+ symbol+"还有"+day +"天")
)
如果日期不是今天到期,就输出“还有多少天”。
else if (day == 0)
document.write("只有1天啦!")
如果到期日就是机器今天的系统日期,则输出“只有一天了”。
else
document.write("唉呀!已经过了!")
否则,就是过期了。


  ///pc/homepage/javascript/sample/img/blank.gif" width="1" height="1">  
 

 

网页制作 网页设计 网站建设 网站设计 网站制作 做网站 做网页