• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Working with Events

We’ve been using events since Chapter 1, “Essential JavaScript.” However, one often uses events as simple notifications that an event—such as a mouse click—occurred so that you can execute your own code. On the other hand, when you’re reading keys or detecting which mouse button was clicked, you need to know more—you need to use the properties of the event object.

The event object has changed a great deal as browsers developed. Chapter 6, “Using Core HTML Methods and Events,” discussed in overview the three major event object models. I reproduce that information in Table 15.1 here, because we need it in this chapter. As you can see, the three major event object models correspond to Netscape Navigator version 4.0, Internet Explorer 4+, and Netscape Navigator 6.0. To read a keystroke in Netscape Navigator 4.0, for example, you use the which property, but to read a keystroke in Internet Explorer 4.0, you use the keyCode property.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint