[whatwg] Details on window.open

Adam Barth w3c at adambarth.com
Sun Oct 7 12:25:32 PDT 2012

On Sun, Oct 7, 2012 at 3:32 AM, David Bruant <bruant.d at gmail.com> wrote:
> I've been searching on the web for complete documentation about
> window.open and I have some unanswered questions.
> 1) what are the rules for popup blockers? Is every call to window.open
> blocked in modern browsers or are there exceptions?

I don't think the spec requires an specific behavior.  Generally
speaking, user agents can be configured as to which sorts of popups
they block.  Most user agents block popup that were not initiated
during a user gesture.

> 2) About the third argument, is there a somewhat interoperable overlap
> in implementations or is it just an intricable mess?
> 3) Is what is returned a instance of Window or WindowProxy?

WindowProxy.  The web platform never returns a direct reference to a
Window object.

> By that I
> mean that if one browsing context A opens C and B window.open C too
> changing the URL (and reloading), is A supposed to have access to the
> new C or only the old browsing context?

The new C.

> 4) About step 4 of The rules for choosing a browsing context given a
> browsing context name [1]:
>> If the given browsing context name is not |_blank| and there exists a
>> browsing context whose name
>> <http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#browsing-context-name>
>> is the same as the given browsing context name, and the current
>> browsing context is allowed to navigate
>> <http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#allowed-to-navigate>
>> that browsing context, and the user agent determines that the two
>> browsing contexts are related enough that it is ok if they reach each
>> other,
> What does "related enough" mean?

That varies by implementation.

> How is it implemented in different browsers?

That's a long, complicated topic.  Some user agents track units of
related browsing contexts.  For example, Chrome ensures that units of
related browsing contexts are not split across process boundaries.  In
Chrome, the search of "related enough" browser contexts stops at
process boundaries.

>> then that browsing context must be the chosen one. If there are
>> multiple matching browsing contexts, the user agent should select one
>> in some arbitrary consistent manner, such as the most recently opened,
>> most recently focused, or more closely related.
> What is the "consistent manner" in each implementation?

You might need to run some experiments to answer this question for yourself.

> [1]
> http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name

More information about the whatwg mailing list