javascript time out function is
settimeout(fun, 3600);
but what if I dont want to run anyother function. can i do settimeout(3600);
?
javascript time out function is
settimeout(fun, 3600);
but what if I dont want to run anyother function. can i do settimeout(3600);
?
You could always pass a handler which does nothing:
setTimeout(function() { }, 3600);
But I can hardly imagine any scenario in which this would be useful.
I'm not sure what you are trying to do. If you want nothing to happen after the period of time, why do you need a setTimeout()
in the first place?
Based on what you are saying you are simply trying to delay execution within a function.
Say for example you want to run an alert, and after 2 more seconds a second alert like so:
alert("Hello")
sleep
alert("World")
In javascript, the only 100% compatible way to accomplish this is to split the function.
function a()
{
alert("Hello")
setTimeout("b()",3000);
}
function b()
{
alert("World");
}
You can also declare the function within the setTimeout itself like so
function a()
{
alert("Hello");
setTimeout(function() {
alert("World");
},3000);
}