Re: addEvent - The late entry :)
- From: "Richard Cornford" <Richard@xxxxxxxxxxxxxxxxxxx>
- Date: Sun, 20 Jul 2008 23:22:31 +0100
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.
.
- References:
- addEvent - The late entry :)
- From: Aaron Gray
- Re: addEvent - The late entry :)
- From: Aaron Gray
- Re: addEvent - The late entry :)
- From: Aaron Gray
- Re: addEvent - The late entry :)
- From: Richard Cornford
- Re: addEvent - The late entry :)
- From: Aaron Gray
- Re: addEvent - The late entry :)
- From: Richard Cornford
- Re: addEvent - The late entry :)
- From: Aaron Gray
- addEvent - The late entry :)
- Prev by Date: Re: addEvent - The late entry :)
- Next by Date: FAQ Topic - How do I POST a form to a new window? (2008-07-21)
- Previous by thread: Re: addEvent - The late entry :)
- Next by thread: Re: addEvent - The late entry :)
- Index(es):
Relevant Pages
|