我有以下内容:
window.setTimeout(function() { window.location.href = 'file.php'; }, 115000);
如何通过 .click 功能在倒计时中途重置计数器?
您可以存储对该超时的引用,然后调用clearTimeout该引用。
clearTimeout
// in the example above, assign the result var timeoutHandle = window.setTimeout(...); // in your click function, call clearTimeout window.clearTimeout(timeoutHandle); // then call setTimeout again to reset the timer timeoutHandle = window.setTimeout(...);