[英]JavaScript setTimeout() in Chrome console
Why setTimeout
doesn't work from Chrome console on some pages or what am I doing wrong? 为什么在某些页面上的Chrome控制台无法使用
setTimeout
或我在做什么错?
setTimeout(function(){console.log('a');},3000);
output: 输出:
<- 6425
Example page: http://olx.pl 示例页面: 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. 编辑:似乎在某些页面上
console.log()
被覆盖了...由于它是特定于站点的问题,因此应删除此问题。 But can't do that, as it has answers. 但是不能这样做,因为它有答案。
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
. 您得到的数字是
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. 每当您调用
setTimeout
或setInterval
它都会返回一个数字ID,然后您可以将其传递给clearTimeout()
或clearInterval()
使其中止运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.