代码示例:(标识:jsck_win_cleartimeout)
<!DOCTYPE html>
<html>
<body>

<h1>Window 对象</h1>

<h2>clearTimeout() 方法</h2>

<p>点击按钮可防止超时执行。(你有 3 秒)。</p>

<h2 id="demo"></h2>

<button onclick="myStopFunction()">停止</button>

<script>
const myTimeout = setTimeout(myGreeting, 3000);

function myGreeting() {
  document.getElementById("demo").innerHTML = "生日快乐!"
}

function myStopFunction() {
  clearTimeout(myTimeout);
}
</script>

</body>
</html>
运行结果: