↑
Main Page
bubbling phase
Figure 9-1
This manner of flow is called
bubbling
because, as displayed in the diagram, the event
bubbles up
the
DOM hierarchy until it reaches the top.
IE changed event bubbling slightly in version 6.0 so that the
<html/>
element also receives the bubbled
events, allowing for code such as this:
<html onclick=”handleClick()”>
<head>
<title>Example</title>
</head>
<body onclick=”handleClick()”>
<div onclick=”handleClick()”>Click Me</div>
</body>
</html>
In this example, a click on the page bubbles back up to the
<html/>
element, causing the previous dia-
gram to change as shown in Figure 9-2.
Figure 9-2
body
body
html
div
div 1
2
3
bubbling phase
bubbling phase
document 4
body
body
document
div
div 1
2
3
bubbling phase
bubbling phase
263
All about Events
12_579088 ch09.qxd 3/28/05 11:39 AM Page 263
Free JavaScript Editor
Ajax Editor
©
→