http://boleyn.iteye.com/blog/1144015
<html> <head> <title> timer_test </title> <meta charset="utf-8"> <script type="text/javascript"> function timeout() { function conf1() { if (confirm("要取消吗")==true) { clearInterval(t); } else { console.log("have not cancel!"); } } // var t=setInterval("conf1()",2000); // 出错咯 var t=setInterval(conf1,2000); } </script> </head> <body> <input type="button" value="click me " onclick="timeout()"> </body> </html>