求百度首页倒计时代码
大年三十百度有发红包活动 你可以点击倒计时 进入活动页面
进去的时候后台取一下当前时间,然后js就可以settimeout()刷时间的文字
<!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" />
<title>限时抢购倒计时间表 by 阿里西西 alixixi.com</title>
<style type="text/css">
*{margin:0;padding:0;}
#content{width:300px;margin:0 auto;padding:10px;background:#eee;border:1px solid #999;}
#content p span{color:red;font:bold 20px Arial;}
#content p a{font:12px/23px '宋体';color:#888;}
.div1{ display:none;}
</style>
</head>
<body><div id="content">
<h1>限时抢购啦!</h1>
<p>还剩<span id="times"></span></p>
</div>
<SCRIPT LANGUAGE="JavaScript">
function fresh()
{
var endtime=new Date("2110/11/06,12:20:12");
var nowtime = new Date();
var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
d=parseInt(leftsecond/3600/24);
h=parseInt((leftsecond/3600)%24);
m=parseInt((leftsecond/60)%60);
s=parseInt(leftsecond%60);
// document.getElementById("times").innerHTML=__h+"小时"+__m+"分"+__s+"秒";
// document.getElementById("times").innerHTML=__d+"天"+__h+"小时"+__m+"分"+__s+"秒";
document.getElementById("times").innerHTML=d+"天"+h+"小时"+m+"分"+s+"秒";
//document.getElementById("times").innerHTML=h+"小时"+m+"分"+s+"秒";
if(leftsecond<=0){
document.getElementById("times").innerHTML="抢购已结束";
clearInterval(sh);
}
}
fresh()
var sh;
sh=setInterval(fresh,1000);
</SCRIPT>
</body>
</html>
谢谢采纳 如有问题 请+Q276021579
function daojishi(sid,maxtime){
if(--maxtime>=0){
hours= Math.floor(maxtime/60/60);
minutes = Math.floor((maxtime-hours*60*60)/60);
seconds = Math.floor(maxtime%60);
msg = "<font color=red>"+hours+"</font> 时 <font color=red>"+minutes+"</font> 分 <font color=red>"+seconds+"</font> 秒";
document.getElementById('dg'+sid).innerHTML=msg;
setTimeout("daojishi("+sid+","+maxtime+")",1000);
}
}
相关视频
时间倒计时代码
倒计时 var now = new Date("11\/26\/2006 " + 10 + ":" + 30 + ":" + 30);function GetServerTime(){ var urodz = new Date("11\/30\/2006 11:38:33");now.setTime(now.getTime()+250);days = (urodz - now) \/ 1000 \/ 60 \/ 60 \/ 24;daysRound = Mat...
JavaScript如何实现倒计时_JavaScript倒计时功能实现与页面显示方法教程...
1. 倒计时基本原理时间差计算:通过Date对象获取目标时间和当前时间的毫秒差。单位转换:将毫秒差转换为天、小时、分钟、秒。定时更新:使用setInterval每秒刷新显示,倒计时结束时清除定时器。2. 完整代码实现HTML部分加载中...JavaScript部分(countdown.js)function startCountdown() { \/\/ 目标时间(...
求倒计时5秒后自动关闭当前页面的代码
倒计时关闭网页 <!-- function clock(){ document.title="本窗口将在"+i+"秒后close!";if(i==0){ clearTimeout(st);window.opener=null;window.close();} i = i -1;st = setTimeout("clock()",1000);} var i=5 clock();\/\/--> ...
倒计时vb代码
十秒倒计时程序代码:Dim N As Integer Private Sub Form_Load()N = 10 Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer()N = N - 1 If N > 0 Then Label1.Caption = N Else Label1.Caption = "时间到"Timer1.Enabled = False End If End Sub ...