4.8. Event Handling
Bring up the subject of client-side events among a group of web developers, and the first (sometimes the only) one mentioned is the onclick event handler. Occasionally, someone will acknowledge the onmouseover and the onmouseout events, but that is usually a rare occurrence, such as leap year or a pay raise after Y2K. Come to think of it, you're more likely to hear a story about someone holding a door open for Walter Koenig than to hear the smallest utterance about another event.
The problem is that developers get into a rut, a comfort zone, and use the same events day in and day out. After a few months of this, we have a tendency to forget that the event handlers are even there. One of the reasons for this is that developing web applications is like riding a bike; when you don't remember how to do it right, there isn't even time to scream before the splat. For this reason, I have compiled Table 4-5, which covers the event handlers common to most browsers. Yes, Bill, that means that the beforeunload event is omitted.
Before wrapping up this chapter, there are some important items that could fall under the umbrella of event handling. Although they aren't really events, they do raise events. The items that I am referring to are the window.setTimeout() and window.setInterval() methods. Don't be surprised if you've never heard of them; they're a little "out there."
var oTime = window.setTimeout('myFunction()',1000); var oInterval = window.setInterval('myYour()',100);
All that is left is what to do when it is necessary to clear a timeout or an interval. It is simple; just do the following, and they're cleared: