Home > Web Front-end > JS Tutorial > body text

Using js to implement event processing model

亚连
Release: 2018-05-19 14:35:19
Original
1420 people have browsed it

This article mainly introduces the use of js to implement event processing models. It has certain reference value for beginners. Interested friends can refer to it.

There are four event models in various browsers: original event model, standard event model, IE event model, and a Netscape4 event model, which will be introduced in detail below.

1. There are currently four event processing models: original event model, standard event model, IE event model, and a Netscape4 event model, but it can basically be ignored

2. The event processing model can be divided into two types: basic event processing and advanced event processing. The original event model belongs to basic event processing, and the standard event model and IE event model belong to advanced event processing

1. Basic event processing :

Basic event processing mainly refers to the event processing implemented by the original event model. It is mainly divided into the following two types:

(1) Event processing as an HTML tag, such as

……              //Here, onmouseover is just a representative, and also includes many other events

In this method, JS code strings are assigned to onmouseover and other event processing functions, and the system will automatically package these code strings in an anonymous function. There can be the this keyword, which points to the tag element, and the event keyword, which represents the event object when the event occurs (used in standard browsers). Such as

……

In fact, we can regard onmouseover, etc. as a function. Before assigning a value to it, it It's just an empty function. After assigning js code to it, it is equivalent to adding code to the empty function. Because onmouseover, etc. are actually a function, we can call it explicitly, such as element.onmouseover(), but this will not cause the mouseover event to actually occur.

You can return false to the event function (i.e. onmoouseover, etc.) to cause the default action to occur.

The function runs in the scope in which it is defined, so if you assign js code to the event processing function, it is equivalent to defining a function in this HTML tag environment. This environment is quite special, and its high The first-level scope is not the window global object environment. There is at least one scope environment between the two. As for the function defined in

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!