Javascript倒计时器 - 采用系统时间自校验

本文介绍了一个改进版的JavaScript倒计时器,通过系统时间自校验来确保倒计时的精确性。在定时器运行过程中,会不断调整定时间隔以补偿代码执行和显示延迟,从而提高倒计时准确性。用户可以点击开始和停止按钮来控制倒计时,并在页面上查看时间差。
摘要由CSDN通过智能技术生成

00:01:11:00
<script language=Javascript> /* This notice must be untouched at all times. countdown.js v. 1.0 The latest version is available at http://blog.csdn.net/yjgx007 Copyright (c) 2004 Xinyi.Chen. All rights reserved. Created 7/30/2004 by Xinyi.Chen. Web: http://blog.csdn.net/yjgx007 E-Mail: chenxinyi1978@hotmail.com Last modified: 7/30/2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; See the GNU General Public License at http://www.gnu.org/copyleft/gpl.html for more details. */ var normalelapse = 100; var nextelapse = normalelapse; var counter; var startTime; var start = clock.innerHTML; var finish = "00:00:00:00"; var timer = null; function run() { startB.disabled = true; endB.disabled = false; counter = 0; startTime = new Date().valueOf(); timer = window.setInterval("onTimer()", nextelapse); } function stop() { startB.disabled = false; endB.disabled = true; window.clearTimeout(timer); } window.onload = function() { endB.disabled = true; } function

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值