O'Reilly logo

The Book of JavaScript, 2nd Edition by thau!

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

Triggering Events

So far all the JavaScript we've seen is triggered when a web page loads into a browser. But JavaScript can also be event driven.

Event-driven JavaScript waits for your visitor to take a particular action, such as mousing over an image, before it reacts. The key to coding event-driven JavaScript is to know the names of events and how to use them.

Event Types

With JavaScript's help, different parts of your web page can detect different events. For example, a pull-down menu can know when it has changed (see Chapter 7); a window when it has closed (see Chapter 5); and a link when a visitor has clicked on it. In this chapter I'll focus on link events.

A link can detect many kinds of events, all of which involve interactions with the mouse. ...

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