<!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=utf-8" />
<title>倒计时</title>
</head>
<body>
<!--单位:秒-->
剩余时间:<span id="endtime">602548</span>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null){
var iTime = document.getElementById(CID).innerHTML;
var Account;
RemainTime();
}
function RemainTime(){
var iDay,iHour,iMinute,iSecond;
var sDay="",sTime="";
if (iTime >= 0){
iDay = parseInt(iTime/24/3600);
iHour = parseInt((iTime/3600)%24);
iMinute = parseInt((iTime/60)%60);
iSecond = parseInt(iTime%60);
if (iDay > 0){
sDay = iDay + "天";
}
sTime =sDay + iHour + "小时" + iMinute + "分钟" + iSecond + "秒";
if(iTime==0){
clearTimeout(Account);
sTime="<span style='color:green'>时间到了!</span>";
}else{
Account = setTimeout("RemainTime()",1000);
}
iTime=iTime-1;
}else{
sTime="<span style='color:red'>此标已过期!</span>";
}
document.getElementById(CID).innerHTML = sTime;
}
</script>
</body>
</html>
倒计时(剩余时间xx天xx小时xx分钟xx秒)
最新推荐文章于 2022-02-16 21:39:24 发布