Menu Event Handlers
 

Event Handlers

In the same manner as my analysis of DOM Objects I am trying to document my experiences as I build and (hopefully) improve my websites

While running the risk of being accused of stating the bleeding obvious, Event Handlers handle events. These events can be simple mouse or keyboard events, such as "onClick()" or events can be added to an object using JavaScript.

Bubbling and Capturing

This concept seems to be key in how events are handled in the DOM. I have attempted to explain what is going on here in a secondary attempt to understand some of the code that I had adopted for some of my layouts. The code for the accordian, not using the W3C Framework started off my inviestigation when I was looking at the syntax of the addEventListener() method.

Apart from understanding what the code does it was a question of why an Event Listener needed to be added to an element. Ojbects will often have built-in event handlers, so why would you need to add another?

When analysing the accordian you can see the real-world application of the bubbling and capturing phases of the object in question. In this case it is a styled button that when clicked opens a "panel" object and then when clicked again closes that "panel". The operation uses the two phases of the handler and the boolean parameter of the addEventHandler() method will determine the display and hiding of the "panel" element.

Top

Site design by Tempusfugit Web Design -