Home >Web Front-end >JS Tutorial >Js operates non-IE event object properties, detailed introduction of methods

Js operates non-IE event object properties, detailed introduction of methods

php中世界最好的语言
php中世界最好的语言Original
2017-11-28 15:02:161470browse

We all know that Event processingfunction is called by the browser. The browser has a listening mechanism that can determine whether the event function has been triggered. This article This article will introduce to you the properties and methods of JS operating non-IE event objects.

Cancelable, type, bubbles are useless, just need to understand

Pay attention to the highlights above, which are the second-level events nested in the second-level events, and the execution of bubbling and capturing Sequence issue, bubbling is from bottom to top, capturing is from top to bottom

There is a question here, what is the difference between the body node and the document node?

You can see the body in the properties under the document object. The document is also the legendary dom area.

But what is displayed now is null? ?

Type is useless, just understand the content

Now it is displayed as undefined in IE, but it is normal in other browsers

It can be used in Google IE, but it can be displayed in Firefox It is not possible. Note that if it is written in the above way, an error will occur in versions below IE8.

In many cases, Google's compatibility is the best. The compatibility problem that usually occurs is between Firefox and IE. The difference, as long as it is valid in IE, it seems to be valid in Google. It is particularly important to note that the above problem will only occur in the second-level event. There is no compatibility issue in the first-level event

Click the button to perform submission, there will be a default behavior Refresh the interface

Just understand the content, only clientX, clientY are used

Encapsulation function: prevent the browser Default behavior, prevent bubbling

Summary: The event processing function is called by the browser. The browser has a listening mechanism to determine whether the event processing function is triggered. Once the event processing function is triggered, the browser When it listens, the event processing function will be called, and then an event source object will be passed to the event processing function. We can actively receive this event source object in the event processing function. Compatibility encapsulation all have one thing in common, which is to obtain the execution context of the function. If it can be obtained, it means it is compatible. If it cannot be obtained, usually, undefined is returned. All the previous The encapsulation compatibility functions are all done in this way.

Pay attention to the execution order of the code here. Each time you click, the above event will be triggered. If the button is clicked, the event will always be triggered. This is a strange phenomenon. Manually control the continuous occurrence of events,

I believe you have mastered the method after reading these cases. For more exciting information, please pay attention to other related articles on the PHP Chinese website!

Related reading:

How to use CSS to hide divs in HTML

How to use CSS to hide the text of the image background Content

How to make DIV adaptive height

The above is the detailed content of Js operates non-IE event object properties, detailed introduction of methods. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn