1var myVar;
2
3function myFunction() {
4 myVar = setTimeout(function(){ alert("Hello"); }, 3000);
5}
6
7function myStopFunction() {
8 clearTimeout(myVar);
9}
1var timer;
2function endAndStartTimer() {
3 window.clearTimeout(timer);
4 var millisecBeforeRedirect = 10000;
5 timer = window.setTimeout(function() {
6 alert('Hello!');
7 }, millisecBeforeRedirect);
8}