博客列表 >简单的倒计时代码

简单的倒计时代码

程序员的博客
程序员的博客原创
2017年11月10日 14:13:401803浏览
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes" >
<title>倒计时代码精确到毫秒</title>
</head>
<body>
<style>
*{margin:0;padding:0}
ul,li{list-style-type:none;}
a{text-decoration:none;outline:none;}
img{border:0;outline:none;max-width:100%;}

.tima1{ display: block; max-width:640px; min-width:320px; width:100%; margin: 0 auto;}
.timeb{ font-weight: bolder; color: red; font-family: Microsoft Yahei; font-size: 105%; background:url(wapx.jpg) no-repeat; background-size:100%; position: fixed;}
.timeb img{ position:relative;}
#timeaa,#timebb,#timecc,#timedd{ position:absolute;}
#timeaa{ top:50%; left:26%;}
#timebb{ top:50%; left:43%;}
#timecc{ top:50%; left:58%;}
#timedd{ top:50%; left:75%;}
</style>
<a href="javascript:void(0)" onclick="openZoosUrl();" class="tima1">
<div class="timeb"><img src="wapx.jpg" />
<span id="timeaa">
<script language="javascript">
function _fresh()
{
 var endtime=new Date("2016/9/01,00:00:00");
 var nowtime = new Date();
 var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
 __d=parseInt(leftsecond/3600/24);
var c=new Date();
var q=((c.getMilliseconds())%10);
 document.getElementById("timeaa").innerHTML=__d;
 if(leftsecond<=0){
 document.getElementById("timeaa").innerHTML="";
 clearInterval(sh);
 }
}
_fresh()
var sh;
sh=setInterval(_fresh,100);
</script>
</span>
<span id="timebb">
<script language="javascript">
function _fresh()
{
 var endtime=new Date("2016/9/01,00:00:00");
 var nowtime = new Date();
 var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
 __h=parseInt((leftsecond/3600)%24);
var c=new Date();
var q=((c.getMilliseconds())%10);
 document.getElementById("timebb").innerHTML=__h;
 if(leftsecond<=0){
 document.getElementById("timebb").innerHTML="活动已结束";
 clearInterval(sh);
 }
}
_fresh()
var sh;
sh=setInterval(_fresh,100);
</script>
</span>
<span id="timecc">
<script language="javascript">
function _fresh()
{
 var endtime=new Date("2016/9/01,00:00:00");
 var nowtime = new Date();
 var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
 __m=parseInt((leftsecond/60)%60);
var c=new Date();
var q=((c.getMilliseconds())%10);
 document.getElementById("timecc").innerHTML=__m;
 if(leftsecond<=0){
 document.getElementById("timecc").innerHTML="活动已结束";
 clearInterval(sh);
 }
}
_fresh()
var sh;
sh=setInterval(_fresh,100);
</script>
</span>
<span id="timedd">
<script language="javascript">
function _fresh()
{
 var endtime=new Date("2016/9/01,00:00:00");
 var nowtime = new Date();
 var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
 __s=parseInt(leftsecond%60);
var c=new Date();
var q=((c.getMilliseconds())%10);
 document.getElementById("timedd").innerHTML=__s+"."+q;
 if(leftsecond<=0){
 document.getElementById("timedd").innerHTML="活动已结束";
 clearInterval(sh);
 }
}
_fresh()
var sh;
sh=setInterval(_fresh,100);
</script>
</span>
</div>
</a>
</body>
</html>
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议