用javascript实现:点击按钮后,页面出现倒计时,并开始倒计时
1个回答
展开全部
<script language='javascript'>
var _t;
var _h = 0;
var _m = 1;
var _s = 0;
var _v = formatTime(_h + ':' + _m + ':' + _s);
function doTime()
{
_s --;
if (_s == -1)
{
_m --;
_s = 59;
}
if (_m == -1)
{
_h --;
_m = 59;
}
var _b = ((_h == 0) && (_m == 0) && (_s == 0));
if (_b)
{
_v = 'Welcome To RTBBS.NET';
clearTimeout(_t);
}
else
{
_v = formatTime(_h + ':' + _m + ':' + _s);
_t = setTimeout('doTime()', 1000);
}
document.all.oTime.innerHTML = _v;
}
function formatTime(_time)
{
return _time.replace(/\b(\w)\b/g, '0$1');
}
function start_time()
{
document.all.oTime.innerHTML = _v;
_t = setTimeout('doTime()', 1000);
}
</script>
<span id='oTime'></span>
<input type="button" name="button2" value="计时开始" onclick='start_time()' >
</body>
</html>
</html>
var _t;
var _h = 0;
var _m = 1;
var _s = 0;
var _v = formatTime(_h + ':' + _m + ':' + _s);
function doTime()
{
_s --;
if (_s == -1)
{
_m --;
_s = 59;
}
if (_m == -1)
{
_h --;
_m = 59;
}
var _b = ((_h == 0) && (_m == 0) && (_s == 0));
if (_b)
{
_v = 'Welcome To RTBBS.NET';
clearTimeout(_t);
}
else
{
_v = formatTime(_h + ':' + _m + ':' + _s);
_t = setTimeout('doTime()', 1000);
}
document.all.oTime.innerHTML = _v;
}
function formatTime(_time)
{
return _time.replace(/\b(\w)\b/g, '0$1');
}
function start_time()
{
document.all.oTime.innerHTML = _v;
_t = setTimeout('doTime()', 1000);
}
</script>
<span id='oTime'></span>
<input type="button" name="button2" value="计时开始" onclick='start_time()' >
</body>
</html>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询