O'Reilly logo

Oracle Application Express 4.0 with Ext JS by Mark Lancaster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining event handlers

Event-driven programming is supported in web browsers through the use of JavaScript to register event handlers and listeners on page elements in the DOM tree. Event handlers provide a mechanism to make a HTML page interactive, so when you click on page elements, or hover over something, JavaScript is executed, and the appearance or behavior of the page changes.

Historically, developers used the Inline model to add event handlers directly to an element as an attribute of the element:

<div id="test" onclick="alert(this.id + ' was clicked');">Click me</div>

Or developers also used the Traditional model to add event handlers via scripts, for example:

<div id="test">Click me</div> <script type="text/javascript> var dom = document.getElementById('test'); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required