在html页面加一个倒计时90分钟代码怎么写

如题所述

<html>
<head>
</head>
<body>
<div id="timeshow">
</div>
<script type="text/javascript">
var time=new Date();
time.setHours(1);
time.setMinutes(30);
time.setSeconds(0);
var timeout;
var timeshow=document.getElementById("timeshow");
function countdown(){
var hour=time.getHours();
var min=time.getMinutes();
var second=time.getSeconds();
if(hour=="0"&&min=="0"&&second=="0"){alert("Time Out!");clearInterval(timeout);}
time.setSeconds(second-1);
hour<10?hour="0"+hour:hour;
min<10?min="0"+min:min;
second<10?second="0"+second:second;
timeshow.innerHTML=hour+":"+min+":"+second;
}
timeout= setInterval(countdown,1000);
</script>
</body>
</html>

初学菜鸟 编的不好请指教
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-03-24
倒计时: <span id="time-left"></span>

<script language="javascript">
var g_iTimeLeft = 90*60;

setInterval(function(){
g_iTimeLeft--;
document.getElementById("time-left").innerHTML = g_iTimeLeft;
},1000);
</script>
第2个回答  2019-03-11
<html>
<head>
</head>
<body>
<div
id="timeshow">
</div>
<script
type="text/javascript">
var
time=new
Date();
time.setHours(1);
time.setMinutes(30);
time.setSeconds(0);
var
timeout;
var
timeshow=document.getElementById("timeshow");
function
countdown(){
var
hour=time.getHours();
var
min=time.getMinutes();
var
second=time.getSeconds();
if(hour=="0"&&min=="0"&&second=="0"){alert("Time
Out!");clearInterval(timeout);}
time.setSeconds(second-1);
hour<10?hour="0"+hour:hour;
min<10?min="0"+min:min;
second<10?second="0"+second:second;
timeshow.innerHTML=hour+":"+min+":"+second;
}
timeout=
setInterval(countdown,1000);
</script>
</body>
</html>
初学菜鸟
编的不好请指教
第3个回答  2010-03-24
需要脚本语言 比如 aps php 等等 或者直接调用FAlSH
第4个回答  2020-12-17
<script type="text/javascript">
setInterval(function() {
var date = new Date();
var EndDate = (new Date('2022-2-4 08:00:00')).getTime();
var ms = EndDate - date;
var seconds = ms / 1000;
var points = seconds / 60;
var hours = points / 60;
var day = hours / 24;
var time = document.getElementById("time");
time.innerHTML = Math.floor(day) + "天" ;

var time1 = document.getElementById("time1");
time1.innerHTML = Math.floor(hours % 24) + "时" ;
var time2 = document.getElementById("time2");
time2.innerHTML = Math.floor(points % 60) + "分";
var time3 = document.getElementById("time3");
time3.innerHTML = Math.floor(seconds % 60) + "秒";
}, 1000)
</script>