建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > javascript学习 > 怎么实现网站倒计时

怎么实现网站倒计时

时间:2015-03-31 10:01:23  来源:免费模板网 作者:风雪 阅读次数 tags网站运用

怎么实现网站倒计时的功能呢,原理就是通过一段js实现
效果如下

<span id="span_dt_dt" style="color:white;background-color:red;font-size:23px">7天9小时29分32秒</span>
<script language="javascript">
<!--
//document.write("");
 
function show_time(){
 window.setTimeout("show_student163_time()", 1000);
 BirthDay=new Date("04-01-2015");//改成你的计时日期
 today=new Date();
 timeold=(BirthDay.getTime()-today.getTime());
 sectimeold=timeold/1000
 secondsold=Math.floor(sectimeold);
 msPerDay=24*60*60*1000
 e_daysold=timeold/msPerDay
 daysold=Math.floor(e_daysold);
 e_hrsold=(e_daysold-daysold)*24;
 hrsold=Math.floor(e_hrsold);
 e_minsold=(e_hrsold-hrsold)*60;
 minsold=Math.floor((e_hrsold-hrsold)*60);
 seconds=Math.floor((e_minsold-minsold)*60);
 
 if(seconds<10){
 seconds="0"+seconds;
 }else{
 seconds=seconds;
 }
 
 span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;
 
}
show_time();
 
</script>

本文地址:https://www.freemoban.com/javascript/2015/0331/1140.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!