javascript - Why is window not identical to window.self in Internet Explorer? -


there's convoluted backstory involving how came across this, why self property not equal window itself?

in safari , firefox , friends, results i'd expect:

> window == window.self   true > window === window.self   true 

the same isn't true in internet explorer, though:

>> window == window.self    true >> window === window.self    false 

can account inconsistency? self property of window object pointing? casts equality, more vexing.

that's not all, window!==window.window!

i believe we're seeing here difference between ‘inner window’ , ‘outer window’ objects. other browsers have these (eg. moz); they're typically used present different view of window inside , outside own code.

the inner window holds global variables , document-specific members. outer window accessible [cross-frame-] scripting via window-references frames[n], parent, opener, , apparently self. bound owner viewport (browser window/frame), eg. when navigate iframe new document, parent document still sees same-identity window object in iframe.

in sensible browser object model design there separate objects this, when javascript thrown netscape there little consideration elegance, resulting in , many other interfaces there overload (form element called submit, anyone?).

so compatibility, split window has continue appear single object scripts though isn't underneath. in ie, mask slips: seems saying window gets inner window, , there's no hack make === against outer window.

eta: come think of it, there's (poor) justification this. ecmascript spec, not written multiple global contexts in mind, defines window, , unbound version of this, retrieving global variable scope object, inner window.

the other properties, being part of dom/bom, not within scope of ecma spec, can return different (and must, sake of cross-frame scripting).


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -