JavaScript's Events and Handlers

Like Visual Basic event procedures, JavaScript supports events and event handlers. When an event occurs, such as the user clicking the mouse, that event's handler executes if you've supplied the handler code. For example, if the user clicks the mouse over a button on a Web page form, the button's onClick event is triggered only if you have written code for it.

In Chapter 18, you saw a JavaScript rollover routine that uses the onMouseOver and onMouseOut event handlers. The code for the onMouseOver event executes automatically when the user viewing the Web page moves the mouse pointer over the button assigned to the onMouseOver event. The code for the onMouseOut event executes automatically when the user viewing ...

Get Absolute Beginner's Guide to Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.