asp 倒计时90分钟代码怎么写
1个回答
2013-11-03
展开全部
倒计时这种功能,用JS比较好。给你一个参考代码:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<title>实时倒计时</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--单位:秒-->
剩余时间:<span id="endtime">10</span>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null)
{
var iTime = document.getElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime()
{
var iDay,iHour,iMinute,iSecond;
var sDay="",sHour="",sMinute="",sSecond="",sTime="";
if (iTime >= 0)
{
iDay = parseInt(iTime/24/3600);
if (iDay > 0)
{
sDay = iDay + "天";
}
iHour = parseInt((iTime/3600)%24);
if (iHour > 0){
sHour = iHour + "小时";
}
iMinute = parseInt((iTime/60)%60);
if (iMinute > 0){
sMinute = iMinute + "分钟";
}
iSecond = parseInt(iTime%60);
if (iSecond >= 0){
sSecond = iSecond + "秒";
}
if ((sDay=="")&&(sHour=="")){
sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
}
else
{
sTime=sDay+sHour+sMinute+sSecond;
}
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>
<html xmlns="www.w3.org/1999/xhtml">
<head>
<title>实时倒计时</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--单位:秒-->
剩余时间:<span id="endtime">10</span>
<script type="text/javascript">
var CID = "endtime";
if(window.CID != null)
{
var iTime = document.getElementById(CID).innerText;
var Account;
RemainTime();
}
function RemainTime()
{
var iDay,iHour,iMinute,iSecond;
var sDay="",sHour="",sMinute="",sSecond="",sTime="";
if (iTime >= 0)
{
iDay = parseInt(iTime/24/3600);
if (iDay > 0)
{
sDay = iDay + "天";
}
iHour = parseInt((iTime/3600)%24);
if (iHour > 0){
sHour = iHour + "小时";
}
iMinute = parseInt((iTime/60)%60);
if (iMinute > 0){
sMinute = iMinute + "分钟";
}
iSecond = parseInt(iTime%60);
if (iSecond >= 0){
sSecond = iSecond + "秒";
}
if ((sDay=="")&&(sHour=="")){
sTime="<span style='color:darkorange'>" + sMinute+sSecond + "</font>";
}
else
{
sTime=sDay+sHour+sMinute+sSecond;
}
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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询