<!DOCTYPE html> <html lang='ja'> <head> <meta charset = 'UTF-8'/> <title>sample</title> <script> window.onload = function(){ var timer; timer = window.setTimeout( function(){ alert('hello'); }, 5000 ); document.getElementById('btn').onclick = function(){ window.clearTimeout(timer); }; }; </script> </head> <body> <input id = "btn" type = "botton" value="タイマー停止"/> </body> </html>