• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 6. Using Core HTML Methods and E... > Using JavaScript’s Core HTML Events

Using JavaScript’s Core HTML Events

Handling events in JavaScript has become complex in recent years because you can now do things three ways: the Netscape Navigator way, the Internet Explorer way, and the W3C way. We’ll take a look at these various techniques and event handling in depth in Chapter 15, “Working with the Mouse, Keyboard, and Images,” but I’ll introduce the topic here. Despite the complexities, we’ll be able to cover at least 95 percent of the typical JavaScript event handling here in this chapter.

Connecting an Event Handler Using Event Attributes

We’ve already seen how to handle events in a general way—you can just use an HTML event attribute such as ONCLICK to connect an event to a JavaScript function, called an event handler. Here’s an example from Chapter 1, “Essential JavaScript.” In this case, I’m connecting a button’s ONCLICK HTML attribute to a JavaScript function named alerter:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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