↑
Main Page
Event capturing
Mozilla 1.0 and higher also supports event bubbling, but to another level. Just like IE 6.0, it supports
events on the
<html/>
element. However, events bubble all the way up to the window object (which is
not a part of the DOM). Using the previous example in Mozilla, clicking the
<div/>
element causes the
event bubbling displayed in Figure 9-3.
Figure 9-3
Event capturing
While Internet Explorer 4.0 used event bubbling, Netscape Navigator 4.0 used an alternate solution
called
event capturing
. Event capturing is just the opposite of bubbling; events fire from the least-specific
object (the
document
object) to the most specific (it was also possible to capture events at the window
level, but that has to be specified explicitly by the developer). Netscape Navigator also doesn’t expose
many elements on the page to events.
Referring again to the previous example, if a user clicks the
<div/>
element using Netscape 4.x, the
event takes the following path:
1.
document
2.
<div/>
body
body
html
div
div 1
2
3
document 4
window
window 5
If you are unsure whether your users will be using IE 5.5 or IE 6.0, it is best to avoid
handling events at the
<html/>
element level.
264
Chapter 9
12_579088 ch09.qxd 3/28/05 11:39 AM Page 264
Free JavaScript Editor
Ajax Editor
©
→