Site icon Tutorial

Event Objects and handlers

Client-side JavaScript programs use an asynchronous event-driven programming model. An object is a construct with properties that are JavaScript variables or other objects. An object also has functions associated with it that are known as the object’s methods.

The event object is a browser object used to get information about a particular event specified. Using event object, user can access information about event happenings. The difference between event object and Event object is such that the latter gives constants that can be used to identify events, while the former is used to get information about events. JavaScript events are items that transpire based on an action. A document event is the loading of an HTML document. A form event is the clicking on a button. Events are objects with properties.

JavaScript defines five types of events which are form, image, image map, link, and window events.

Events are associated with HTML tags. The definitions of the events described below are as follows:

Event Handler – Applications register their event handler functions with the web browser, specifying an event type and an event target. When an event of the specified type occurs on the specified target, the browser invokes the handler. Event objects are passed as an argument to the event handler function. Event handlers are linked to HTML tags as

Syntax Example                 
onEvent = “Code to handle the event” <input type=”button” value=”Click Me!” onclick=”window.alert(‘Hi!’);” />

Back to Tutorial

Exit mobile version