Event Propagation

In the beginning, an event is fired on an object, such as mouseover on a link around an image. If there was an event handler defined for that event (onmouseover, in this case), then that event handler executed. Consider the following code:

<a href="go.html" onmouseover="swapImage(1)"
  onmouseout="swapImage(0)">
<img src="link.gif" name="linkImg"></a>

If there was no event handler, then the event vanished into oblivion. In other words, the only way JavaScript would ever know an event occurred is if there was some sort of event handler in place to notice the event occurred.

For the version 4 browsers and above, events don't live such simple lives. They're pushed through a number of different nodes. We'll see how this works in ...

Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.