Why setTimeout
doesn't work from Chrome console on some pages or what am I doing wrong?
setTimeout(function(){console.log('a');},3000);
output:
<- 6425
Example page:
EDIT: Seems that on some pages console.log()
is being overridden ... as it's site specific problem, this question should be deleted. But can't do that, as it has answers.
Why setTimeout
doesn't work from Chrome console on some pages or what am I doing wrong?
setTimeout(function(){console.log('a');},3000);
output:
<- 6425
Example page: http://olx.pl
EDIT: Seems that on some pages console.log()
is being overridden ... as it's site specific problem, this question should be deleted. But can't do that, as it has answers.
window.setTimeout()
on MDN.
– Etheryte
Commented
Oct 16, 2017 at 19:21
6425
is the timeout id. So clearly it is at least creating the timeout. In 3 seconds, it should call the function. So why would it not show the log? Well is your console filtered to not show log lines?
– epascarello
Commented
Oct 16, 2017 at 19:26
It does work. The catch is you may not be waiting enough.
console.log(setTimeout(() => console.log('a'), 1000));
That number you get is the timeoutId
. Anytime you call setTimeout
or setInterval
it returns a numeric ID which you can then pass to clearTimeout()
or clearInterval()
to abort it before it runs.