views:

24

answers:

1

The book Professional Javascript by Zakas says that

1) IE uses event bubbling
2) Netscape uses event capturing
3) DOM event flow is first capturing and then bubbling

So, won't the event handler be called twice? What is this DOM event flow, is it the DOM level 2 event handling?

As I understands it, is the following true?

a) IE 6, 7, 8 all uses bubbling
b) FF, Chrome, Safari, Opera all use capturing?
c) jQuery makes everything the same by making it "bubbling"

+3  A: 

Maybe this link can shed some light on event propagation

dpb
+1, that is a great explanation.
Andy E
so the short answer is, the addEventListener() call can have an argument to signal whether wanting to be triggered in the capturing or bubbling phase.
動靜能量
what about a, b, c above?
動靜能量
@Jian Lin: When an event is triggered, the event propagates from the root of the DOM tree down to the target element (capturing) andthen propagates again from the target element up to the root (bubbling). This is what's called DOM Level 2 Event Model (w3c standard). The old event model, called DOM Level 0 Event Model, only does bubbling. IE does not support DOM Level 2 Events (has similar proprietary behavior if I remember well; not sure if IE8 fixed this). Because of differences between browsers (some support one model, some the other), jQuery abstracts the thing and only does bubbling.
dpb
@Jian Lin: regarding the addEventListener call, I won't resume it to that. IE defines its own method named attachEvent for this (not sure for IE8 though, maybe they fixed it in this version). So the thing is the event model is a standard, but different browsers have different compliance levels.
dpb