我们小时候都希望时光能够倒流,那该如何实现倒计时呢?下面博主我打了一些代码,想实现倒计时的宝宝们,可以尝试打一下哦!
<html >
<head>
<title>倒计时</title>
<script type="text/javascript">
function showtime(){
var hdate=new Date('2018-11-27 00:00:00');
var curdate=new Date;
var ctime=Date.parse(curdate)/1000;
var difftime=htime-ctime;
var mydiv=document.getElementById('result');
var day=difftime/(3600*24);
var intday=parseInt(day);
var hour=(day-intday)*24;
var inthour=parseInt(hour);
var minute=(hour-inthour)*60;
var intm=parseInt(minute);
var second=(minute-intm)*60;
var ints=Math.round(second);
var timestr=difftime;
mydiv.innerHTML=intday+'天'+inthour+'小时'+intm+'分钟'+ints+'秒';
t=setTimeout('showtime()',1000);
}
window.οnlοad=showtime;
</script>
</head>
<body>
<div id="result">
</div
></body>
</html>