您的位置:首页 > 其它

倒计时(剩余时间xx天xx小时xx分钟xx秒)

2015-09-08 10:46 337 查看
<!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>

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: