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

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-10   浏览: 447 ::
收藏到网摘: 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天和过去后的提示语,也都可以修改。