Re: addEvent - The late entry :)



Aaron Gray wrote:
Richard Cornford wrote:
Aaron Gray wrote:
Richard Cornford wrote:
Aaron Gray wrote:
Here's yet another mod :-

if ( window.addEventListener) {

The W3C - EventTarget - interface is specified as being implemented
by objects implementing the core DOM Node interface (and in reality
are only reliable on objects implementing Element). The window
object is not a Node and so it is not valid to infer that if a
window object has an - EventTarget - method then all Nodes/Elements
will, or vice versa. Opera 7, for example, had an - attachEvent -
method on its window objects but no - addEventListener -, while
all of its nodes had - addEventListener - methods. Thus you are
forcing Opera 7 to use the (less efficient) attachEvent branch
having previously asserted that Opera browsers did not work
particularly well with that branch.

Okay I have made a mod here then :-

if ( typeof addEventListener != "undefined")
...

This appears to function correctly on IE, FF, Safari, and Opera.

You have completely missed the point. The test was fine (well, the
test is actually debatable but I would have no problem with it),
it is the inference made from the test that is unfounded.

So Opera needs a special case calling attachEvent on windows instead
of addEventListener ?

Event handing on objects outside of the DOM (which pretty much comes down to window/frame objects) needs to be handled completely independently of event handling on elements within the DOM. Any parallels between the two should be regarded as fortunate coincidences rather than as being related (or implying a relationship). (And then being cautious about load and unload events)

Richard.

.



Relevant Pages

  • Re: addEvent - The late entry :)
    ... window object has an - EventTarget - method then all Nodes/Elements ... Opera 7, for example, had an - attachEvent - ... all of its nodes had - addEventListener - methods. ... forcing Opera 7 to use the attachEvent branch ...
    (comp.lang.javascript)
  • Re: Event Listeners : window vs document
    ... to prefixing a call to addEventListener or attachEvent. ... handler property of the object referred to by `window'. ... read the W3C DOM Level 2+ Event Specifications where the ...
    (comp.lang.javascript)
  • Re: OT - Woodstocks in Venice - Part the Second
    ... spent a lot of time in less touristy neighborhoods ... opera. ... A Venetian matron, perhaps in her seventies, was ... | in every window - whirligigs, banners, flags, windsocks, all in colorful ...
    (rec.arts.mystery)
  • Opera: Location, Location, Location (GM#008-OP)
    ... Opera 7.53 and prior on Windows, ... The advisory depicted several flaws in Opera's ... write-access to objects on the victim window. ... GreyMagic Software is not liable for any direct or indirect damages caused ...
    (Bugtraq)
  • [VulnWatch] Opera: Location, Location, Location
    ... Opera 7.53 and prior on Windows, ... The advisory depicted several flaws in Opera's ... write-access to objects on the victim window. ... GreyMagic Software is not liable for any direct or indirect damages caused ...
    (VulnWatch)