Web design programs - 721Chapter 29 .Event Objects (with the event object
721Chapter 29 .Event Objects (with the event object being passed as a parameter, such as the other methods). As long as the target object has an event handler defined for that event, it will process the event as if it had received the event directly from the system (even though the event object s targetproperty may be some other object entirely). To demonstrate how this event redirection works, Listing 29-4 includes the final additions to the document being built so far in this chapter. The listing includes mechanisms that allow all click events to be sent directly to the second button in the layer (layerButton2). The previous interaction with document and layer event capture and routing is still intact, although you cannot have event routing and redirection on at the same time. The best way to see event redirection at work is to enable both document and layer event capture (the default settings). When you click the main1button, the event reaches only as far as the document-level capture handler. But if you then turn on the Send event to layerButton2 checkbox associated with the document level, a click of the main1button reaches both the document-level event handler and layerButton2, even though the main1button is not anywhere near the layer button in the document object hierarchy. Click other checkboxes to work with the interaction of event capturing, routing, and redirection. Listing 29-4: NN4 Redirecting Events