当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 利用JavaScript制作倒计时牌

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 利用JavaScript制作倒计时牌


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 450 ::
收藏到网摘: n/a

利用JavaScript制作倒计时牌

  五一劳动节很快就到了。哈哈,到时可以出去好好玩一玩了。是不是在掐指计算了。下面教你一种方法在网页上面制作倒计时牌,这样就方便多了。

  把下面的JavaScript代码加入到< body >< /body >中即可。

< script language="JavaScript" >
var urodz= new Date("5/1/2002");
var s="今天离五一劳动节";
var now = new Date();
var ile = urodz.getTime() - now.getTime();
var dni = Math.floor(ile / (1000 * 60 * 60 * 24));
if (dni > 1)
document.write(""+s+"还有"+dni +"天")
else if (dni == 1)
document.write("只有2天啦!")
else if (dni == 0)
document.write("只有1天啦!")
else
document.write("好象已经过了哦!");
< /script >


注释:第2行是设置目标的日期,格式为"月/日/年"。第3行是设置提示语,可根据不同情况不同设置。后面还有剩下1天、2天和过去后的提示语,也都可以修改。