Skip to content Skip to sidebar Skip to footer

Why Is Window.open() Silently Ignored Iff Called From Within A Loop And Via Settimeout()?

--- EDIT. I don't get it; yesterday it seemed to be ignored; now it seems to be working. Even within loop and called via setTimeout(). Currently I seem to be having difficulties re

Solution 1:

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.

In essence, trying to fire window.openfrom withinsetTimeout() leaves the browser to "think" it's a popup which deserves (silent) blocking. -- If, in contrast, window.open is fired on it's own, the browser treats seems to treat it like a "user click", that is, not as spam to be blocked.

Post a Comment for "Why Is Window.open() Silently Ignored Iff Called From Within A Loop And Via Settimeout()?"