I was creating a program which should stop automatically a <b>
. So please tell me how, here is a little bit I am thinking off:
var time = date.getTime();
var seconds = 0;
if (time + seconds == date.getTime())
{
// Stop everything i do by myself :)
}
I was creating a program which should stop automatically a <b>
. So please tell me how, here is a little bit I am thinking off:
var time = date.getTime();
var seconds = 0;
if (time + seconds == date.getTime())
{
// Stop everything i do by myself :)
}
Share
Improve this question
edited Dec 18, 2017 at 16:47
vinS
1,4755 gold badges25 silver badges39 bronze badges
asked Feb 10, 2017 at 15:44
modifyermodifyer
671 gold badge2 silver badges7 bronze badges
2
-
use a
setTimeout
. – Daniel A. White Commented Feb 10, 2017 at 15:45 - Yes but i dont want to use this ;) – modifyer Commented Apr 14, 2017 at 12:50
2 Answers
Reset to default 5Something like this:
var keepGoing = true;
setTimeout(function(){
keepGoing = false;
}, 1000 * 60 * 60); //one hour
while(keepGoing){
//stuff to do
}
We can use a bination of setInterval
and setTimeout
to acplish this.
function doStuff(){
//do whatever you need to do
}
var is_running = true;
setTimeout(function(){
is_running = false; //Stop the program
}, 1000 * 60 * 60); //Do this after 1 hour
while(is_running){
doStuff(); //whatever your function does
}