Event Processing overview event processing is an important part of object-oriented programming. Without event processing, the program will become very dead and lacks flexibility. The process of event processing can be like this: Event-start event handler-event handler to respond. SyntaxHighlighter. all ();
Event handling Overview
Event processing is a very important part of object-oriented programming. Without event processing, the program will become very dead and lacks flexibility. The process of event processing can be like this: Event-start event handler-event handler to respond. To enable the event handler to start, you must first tell the object what handler to start if something happens. Otherwise, the process cannot proceed. The event handler can be any JavaScript statement, but we usually use a specific custom function to handle the event.
There are three methods to specify an event handler:
Method 1 is directly specified in the HTML Tag. This method is the most common. The method is:
<标记 ... 事件="事件处理程序" [事件="事件处理程序" ...]>
Let's take a look at the example:
Such definitionMark to enable a dialog box to pop up when the document is read, saying "webpage reading is complete, please enjoy it slowly"; when the user exits the document (or closes the window, or goes to another page) "Goodbye" is displayed ".
Method 2: Compile the JavaScript code for a specific object event. This method is rarely used, but it is useful in some scenarios. The method is: