首页 > 代码库 > JS倒计时
JS倒计时
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>网页倒计时</title><script language="JavaScript"> <!-- hide script from old browser var DifferenceHour = -1 var DifferenceMinute = -1 var DifferenceSecond = -1 var Tday = new Date("Aug 27, 2014 20:00:00") //**倒计时时间点-注意格式 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 = time.getHours() var minute = time.getMinutes() var second = time.getSeconds() var timevaluehttp://www.mamicode.com/= "" + ((hour > 12) ? hour - 12 : hour) timevalue += ((minute < 10) ? ":0" : ":") + minute timevalue += ((second < 10) ? ":0" : ":") + second timevalue += ((hour > 12) ? " PM" : " AM") var convertHour = DifferenceHour var convertMinute = DifferenceMinute var convertSecond = DifferenceSecond var Diffms = Tday.getTime() - time.getTime() DifferenceHour = Math.floor(Diffms / daysms) Diffms -= DifferenceHour * daysms DifferenceMinute = Math.floor(Diffms / hoursms) Diffms -= DifferenceMinute * hoursms DifferenceSecond = Math.floor(Diffms / Secondms) Diffms -= DifferenceSecond * Secondms var dSecs = Math.floor(Diffms / microsecond) if (convertHour != DifferenceHour) document.formnow.dd.value = http://www.mamicode.com/DifferenceHour"clock()", 1000) } // end hiding --> </script></head><body onl oad="clock();return true">倒计时:<br><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>
JS倒计时
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。