Chapter 11. Browser Events
To add actual useful functionality to a web page, we need to do more than inspecting and modifying the document—we must be able to detect the user’s actions and respond to them. This is done by handling events, which are the subject of this chapter.
Key presses, scrolling, mouse clicks, and even mouse motion are all turned into
events by your browser, and we can write code to
handle them. For example, in Chapter 9, we set the
property of a button to do some-thing when that button was clicked. That was an example of a
simple event handler.
The way browser events work is, fundamentally, very simple. It is possible to register handlers for specific event types on specific DOM nodes. Whenever an event ...