当Windows进入睡眠模式然后唤醒时,settimeout无效 [英] settimeout is not working when Windows goes to sleep mode and then wake up
问题描述
我在Chrome中注意到了这一点。任何人都知道什么是错误或解决方法?
I have noticed this in Chrome . Anyone has a idea about what's wrong or a workaround ?
推荐答案
你可以使用 setInterval
相反 - 它继续运行。如果您需要一次性解决方案,请使用 clearInterval
删除计时器。如果计算机在事件应该被触发时处于睡眠状态, setInterval
将立即触发。我在Chrome,Firefox和Internet Explorer中测试了这种行为。例如,请查看 http://blaeul.de/de/content/javascript-计时器测试及其来源。
You can use setInterval
instead - it keeps on running. If you need a one-shot solution, use clearInterval
to delete the timer. setInterval
will fire immediately if the computer was asleep while the event should have been fired. I tested this behavior in Chrome, Firefox and Internet Explorer. As an example, have look at http://blaeul.de/de/content/javascript-timer-test and its source.
这篇关于当Windows进入睡眠模式然后唤醒时,settimeout无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!