we’ve used and abused window.open for years, and most of us know the basic mechanics pretty well. some thing you might not know:

  1. in modern browsers, window.open will open in a new tab rather than a popup.
  2. you can force a browser to use a new window (‘popup’) by specifying options in the 3rd parameter
  3. if the window.open call was not part of a user-initiated event, it’ll open in a new window.
  4. a “user initiated event” does not have to the same function call – but it must originate in the function invoked by a user click
  5. if a user initiated event delegates or defers a function call (in an event listener or delegate not bound to the click event, or by using setTimeout for example), it loses it’s status as “user initiated”
  6. some popup blockers will allow windows opened from user initiated events, but not those opened otherwise.
  7. if any popup is blocked, those normally allowed by a blocker (via user initiated events) will sometimes also be blocked.

Some examples…

Forcing a window to open in a new browser instance, instead of a new tab:

The following would qualify as a user-initiated event, even though it calls another function:

The following would not qualify as a user-initiated event, since the setTimeout defers it: