Timeline for Simulating JavaScript's setTimeout() method "from first principles"
Current License: CC BY-SA 4.0
Post Revisions
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 14, 2018 at 8:39 | comment | added | nutty about natty | spawed a new, separate question from this here: stackoverflow.com/questions/50326060/… | |
| May 12, 2018 at 17:41 | comment | added | nutty about natty |
Popup blockers in most popular browsers will only allow a new window to be opened if it is opened as a result of code running from a direct user action such as a click. Because a setTimeout() happens some time in the future, is not considered the direct result of a user action so attempts to open windows from setTimeout() are likely blocked by the popup blocker.
|
|
| May 12, 2018 at 17:32 | comment | added | nutty about natty |
@skyboyer Your argument would make sense if window.open("https://www.bbc.com","_self"); - without setTimeout() - would not work as well; but it does. Why would the browser only block a delayed window.open but not an immediate one? Also, where could I see evidence of the "blocking" (Scratchpad does not, as far as I can tell, inform the user); tried console.log(...) but that didn't return anything either :(
|
|
| May 12, 2018 at 11:25 | comment | added | skyboyer |
hold on, under "popup window" I didn't mean alert(i) but all that new windows you are about to open
|
|
| May 12, 2018 at 7:37 | comment | added | nutty about natty |
@skyboyer No, the alert(i); is just a place-holder and that actually works (an alert is displayed on every loop); however, window.open() is ignored.
|
|
| May 12, 2018 at 7:32 | comment | added | skyboyer |
you can ensure there is nothing wrong with setTimeout with replacing window.open to console.log
|
|
| May 12, 2018 at 7:30 | comment | added | skyboyer |
so you are trying to open new popup windows. a lot. in the loop. browser just blocks this as a spam. there is nothing wrong with setTimeout
|
|
| May 12, 2018 at 7:25 | comment | added | nutty about natty | @skyboyer of course; added in the edit. | |
| May 12, 2018 at 7:21 | history | edited | nutty about natty | CC BY-SA 4.0 |
added 635 characters in body
|
| May 12, 2018 at 7:04 | history | edited | nutty about natty | CC BY-SA 4.0 |
added 114 characters in body
|
| May 12, 2018 at 6:21 | answer | added | Nina Lisitsinskaya | timeline score: 3 | |
| May 12, 2018 at 5:41 | answer | added | CertainPerformance | timeline score: 1 | |
| May 12, 2018 at 5:34 | comment | added | skyboyer |
you better add code snippet. setTimeout works maybe even since 199x. it's more probable you misuse it rather it's broken
|
|
| May 12, 2018 at 5:29 | comment | added | CertainPerformance |
loop through a check to see if, say, 10 seconds (or 5 minutes) have passed, before continuing Wouldn't this necessarily block?
|
|
| May 12, 2018 at 5:25 | history | asked | nutty about natty | CC BY-SA 4.0 |