In answering my question Pumbaa80 found a difference between calling open()
and window.open()
, try the following examples in Firefox
Inside the event handler, open
by itself will resolve to document.open
. As Boris Zbarsky mentioned in a comment and in his answer, this is expected behavior, specified by HTML5. In the section on event handlers, step 6 specifies:
6. Using the script execution environment created above, create a function object (as defined in ECMAScript edition 5 section 13.2 Creating Function Objects), with:
(...)
Lexical Environment Scope
- Let Scope be the result of NewObjectEnvironment(the element's Document, the global environment).
- If the element has a form owner, let Scope be the result of NewObjectEnvironment(the element's form owner, Scope).
- Let Scope be the result of NewObjectEnvironment(the element's object, Scope).
(...)
In other words, variable references within the event handler will be resolved in the order:
document
properties