给你一段我收藏倒计时功能的代码,复制了保存为html文件,亲测可用。
<html>
<head>
<title>生日倒计时</title>
<b>今天距离2014年8月2日的生日还有</b><br>
<script language="JavaScript">
var DifferHour = -1
var DifferMinute = -1
var DifferSecond = -1
var Tday1 = new Date("2014-08-02") //倒计时时间-注意格式
var daysms = 24 60 60 1000
var hoursms = 60 60 1000
var Secondms = 60 1000
var microsecond = 1000
function clock()
{
var time = new Date()
var hour = timegetHours()
var minute = timegetMinutes()
var second = timegetSeconds()
var timevalue = ""+((hour > 12) hour-12:hour)
timevalue +=((minute < 10) ":0":":")+minute
timevalue +=((second < 10) ":0":":")+second
timevalue +=((hour >12 ) " PM":" AM")
var convertHour = DifferHour
var convertMinute = DifferMinute
var convertSecond = DifferSecond
var Diffms = Tday1getTime() - timegetTime()
DifferHour = Mathfloor(Diffms / daysms)
Diffms -= DifferHour daysms
DifferMinute = Mathfloor(Diffms / hoursms)
Diffms -= DifferMinute hoursms
DifferSecond = Mathfloor(Diffms / Secondms)
Diffms -= DifferSecond Secondms
var dSecs = Mathfloor(Diffms / microsecond)
if(convertHour != DifferHour) documentformnowddvalue=DifferHour
if(convertMinute != DifferMinute) documentformnowhhvalue=DifferMinute
if(convertSecond != DifferSecond) documentformnowmmvalue=DifferSecond
documentformnowssvalue=dSecs
documentformnowssvalue=dSecs
// documentformnowTnowvalue= DifferHour DifferMinute + DifferSecond + dSecs
setTimeout("clock()",1000)
}
</script>
</head>
<body onload="clock();return true" text="red">
<form name="formnow">
<input name="dd" type="text" style="border:0;" size=2>
天
<input name="hh" type="text" style="border:0;" size=2>
小时
<input name="mm" type="text" style="border:0;" size=2>
分
<input name="ss" type="text" style="border:0;" size=2>
秒
</form>
</body>
</html>
许多人认为婕斯沛泉太好了,殊不知要加上DNA早晚系列可以达到加乘,事半功倍[呲牙]
知道你吃的AMPM功能有多强大吗?
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)