asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Dynamic HTML > Understanding Events

Dynamic HTML

Previous: DHTML Overview   Next: Handling Events


Understanding Events

This chapter describes events and event handlers and how we can use them in our documents.

Events and Handlers Quick Start

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 occurred.

This 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.


More ...
Back to top


© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

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