aspxtreme

Dynamic HTML

Abakada ~ Back to Basics


Understanding Events and Handlers

An event is a predefined document condition ( such as when a document loads ), or some form of user interaction with its elements ( such as when a user clicks the mouse or presses a key ) while viewing the document. We use events to assign a certain action to be done when the event occurs, basically in the following notation:

<element event="event handler">

An event handler is code, typically a function written in a scripting language, that receives control when the corresponding event occurs. Some events have default handlers, as when we click on a hyperlink, that normally loads another page. DHMTL, though, allows us the flexibility to define and attach our own event handler that will also be called whenever the event occurs. For example,

<img src="image.gif" onclick="doThis ( );">

Each event that occurs in turn is stored as the current event object in memory, along with the properties and methods associated with the particular event that occured. The event object can be accessed via script, and provides a way for authors to determine specific event attributes, such as which element the event occurred, which mouse button was clicked, the mouse location, etc., and use these values for whatever purposes we can imagine.

NOTE: The discussions here cover client-side events, or events that are caused and handled at the browser level. Server-side events and handlers are discussed separately in the ASP.NET workshop.

Types of Events

Events are classified into either of the following:

  • Load and Readystate Events
  • Mouse Events
  • Keyboard Events
  • Focus and Selection Events
  • Other Events

Now let's take a closer look at what all these are about.



Books and more ...

Contents
DHTML Overview
Understanding Events and Handlers
Dynamic Styles
Dynamic Content
Dynamic Positioning
Windows and Frames
Filters and Transitions
DHTML Objects Reference
DHTML Events Reference
 


Suggested Reading


More ...
Back to top

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme