<html>
<head>
<title>Tomato</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
var vTimeLength = 5;
var vHour;
var vMinutes;
var vSeconds;
var vRemainingTime;
function countDown(){
vTimeLength = vTimeLength - 1;
vMinutes = Math.floor(vTimeLength/60);
vSeconds = Math.floor(vTimeLength%60);
if (vMinutes >= 60){
vHour = Math.floor(vMinutes/60);
var vMinutesNew = Math.floor(vMinutes%60);
vRemainingTime = vHour + ":" + vMinutesNew + ":" + vSeconds;
} else {
vRemainingTime = vMinutes + ":" + vSeconds;
}
document.getElementById("div_countDown").innerHTML = vRemainingTime;
if (vTimeLength < 1) {
alert('do sth');
}
}
</script>
</head>
<body>
<div id="div_countDown"></div>
<script type="text/javascript">
setInterval("countDown()", 1000);
</script>
</body>
</html>
<html>
<head>
<title>countdown</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function countDown(vTimeLength, showTagId, callback) {
var vHour;
var vMinutes;
var vMinutesNew
var vSeconds;
var vRemainingTime;
function countDownInner(vTimeLength){
vMinutes = Math.floor(vTimeLength/60);
vSeconds = Math.floor(vTimeLength%60);
if (vMinutes >= 60){
vHour = Math.floor(vMinutes/60);
vMinutesNew = Math.floor(vMinutes%60);
vRemainingTime = vHour + ":" + vMinutesNew + ":" + vSeconds;
} else {
vRemainingTime = vMinutes + ":" + vSeconds;
}
document.getElementById(showTagId).innerHTML = vRemainingTime;
vTimeLength = vTimeLength - 1;
if (vTimeLength > 0) {
setTimeout(function(){countDownInner(vTimeLength);}, 1000);
} else {
callback();
}
}
countDownInner(vTimeLength);
}
</script>
</head>
<body>
<div id="div_countDown"></div>
<script type="text/javascript">
countDown(5, "div_countDown", function(){alert('do sth');});
</script>
</body>
</html>
<html>
<head>
<title>count_down</title>
<script type="text/javascript">
var countDown = {
flag: true,
hour: 0,
minutes: 0,
minutesNew: 0,
seconds: 0,
show: 0,
current: 0,
length: 0,
showTagId: null,
// callback: null,
countDownInner: function(vTimeLength){
if (!this.flag) {
return;
}
var that=this;
this.current = vTimeLength;
minutes = Math.floor(vTimeLength/60);
seconds = Math.floor(vTimeLength%60);
if (minutes >= 60){
hour = Math.floor(minutes/60);
minutesNew = Math.floor(minutes%60);
show = hour + ":" + minutesNew + ":" + seconds;
} else {
show = minutes + ":" + seconds;
}
document.getElementById(this.showTagId).innerHTML = show;
vTimeLength = vTimeLength - 1;
if (vTimeLength > 0) {
setTimeout(function(){that.countDownInner(vTimeLength);}, 1000);
} else {
setTimeout(function(){that.callback();}, 1000);
}
},
run: function(vTimeLength, showTagId, callback) {
if (!this.flag) {
this.flag = true;
this.countDownInner(this.current);
} else if (showTagId) {
this.length = vTimeLength;
this.showTagId = showTagId;
this.callback = callback;
this.countDownInner(vTimeLength);
}
},
stop: function(){
this.flag = false;
},
restart: function(){
this.flag = true;
this.countDownInner(this.length);
}
};
function countDownStart() {
countDown.run();
}
function countDownStop() {
countDown.stop();
}
</script>
</head>
<body>
<div id="div_countDown"></div>
<script type="text/javascript">
countDown.run(5, 'div_countDown',function(){alert('12')});
</script>
<span>
<button onclick="countDownStart();">start</button>
<button onclick="countDownStop();">stop</button>
</span>
</body>
</html>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有