This commit is contained in:
Ilya Kantor 2019-05-17 09:33:50 +03:00
parent 55f599ed28
commit da3ba6a072

View file

@ -127,10 +127,10 @@ let timerId = setInterval(() => alert('tick'), 2000);
setTimeout(() => { clearInterval(timerId); alert('stop'); }, 5000); setTimeout(() => { clearInterval(timerId); alert('stop'); }, 5000);
``` ```
```smart header="Modal windows freeze time in Chrome/Opera/Safari" ```smart header="Time goes on while `alert` is shown"
In browsers IE and Firefox the internal timer continues "ticking" while showing `alert/confirm/prompt`, but in Chrome, Opera and Safari the internal timer becomes "frozen". In most browsers, including Chrome and Firefox the internal timer continues "ticking" while showing `alert/confirm/prompt`.
So if you run the code above and don't dismiss the `alert` window for some time, then in Firefox/IE next `alert` will be shown immediately as you do it (2 seconds passed from the previous invocation), and in Chrome/Opera/Safari -- after 2 more seconds (timer did not tick during the `alert`). So if you run the code above and don't dismiss the `alert` window for some time, then in the next `alert` will be shown immediately as you do it. So the actual interval between alerts will be shorter than 5 seconds.
``` ```
## Recursive setTimeout ## Recursive setTimeout