[whatwg] Details on window.open
ian at hixie.ch
Tue Dec 18 15:53:19 PST 2012
On Sun, 7 Oct 2012, David Bruant 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?
Per the spec, calls that would create a new browsing context are blocked
unless called from the handler of a trusted 'click' event. (The spec also
allows blocking in some other cases, and requires blocking in some sandbox
cases, but those aren't popup-blocking-related.)
I don't know if the spec is overly strict here; maybe it should also be
possible on other trusted events e.g. mousedown or keydown?
> 2) About the third argument, is there a somewhat interoperable overlap
> in implementations or is it just an intricable mess?
I haven't tried to spec it, because as far as I can tell, UAs could
completely ignore it with no ill effects. If I'm wrong about this, then we
should spec something.
> 3) Is what is returned a instance of Window or WindowProxy? 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?
You can never get hold of a raw Window object, only WindowProxy objects.
In your scenario, provided it's all same-origin, A will have an object
that reflects that the browsing context has a new document loaded in it.
(It's only one browsing context though.)
> 4) About step 4 of The rules for choosing a browsing context given a
> browsing context name :
> > If the given browsing context name is not |_blank| and there exists a
> > browsing context whose name is the same as the given browsing context
> > name, and the current browsing context is 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's up to the UA.
> How is it implemented in different browsers?
It varies. Gecko, IIRC, thinks everything is related enough. Chrome
probably limits it to same-process windows.
> > 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?
I do not know. I hope that this doesn't matter for interop; if I'm wrong,
let me know and we shall spec it.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg