Java Reference
In-Depth Information
10
Events
What You Will learn in this Chapter:
➤
Connecting your code to events to respond to user actions
➤
Writing standards‐compliant, event‐driven code
➤
Writing event code for older versions of Internet Explorer
➤
Handling the difference between standards‐compliant and old‐IE
event models
➤
Dragging and dropping content with HTML5's native drag‐and‐drop
capabilities
➤
Animating elements by manipulating their positioning
Wrox.Com Code doWnloads for this Chapter
You can find the wrox.com code downloads for this chapter at
http://www.wiley.com/go/
BeginningJavaScript5E
on the Download Code tab. You can also view all of the examples
There's no doubt that JavaScript is a useful tool in web programming. You've seen how to
dynamically create, remove, and manipulate HTML in the page, and in the coming chapters,
you learn how to process user input and send data to the server.
Although these capabilities are very important in today's web programming, perhaps the
most important concept you'll learn and use is that of
events
. In the real world, an event is,
put simply, something that happens. For example, a ringing telephone is an event. If you are
expecting a friend or colleague to call, you usually want to do something: Answer the call.
In programming, events are very similar to a telephone call. Something in the page will
happen, and if it's something you are expecting, you can respond to it. For example, the
user clicking the page, pressing a key on the keyboard, or moving the mouse pointer over