[DOM Event Learning] section 2 concept comb what is event DOM events
Eventsevent is used to inform the code that something interesting has happened.each event is represented by an event object, which may have some custom fields or methods to get more information about what's going on.the event object implements the event interface (https://developer.mozilla.org/en-US/docs/Web/API/Event). events can be anything from the most basic user interaction to something that happens automatically in the rendering model.There are some standard events in the official specification, and there are internal events that are used by specific browsers.Various events can be consulted: https://developer.mozilla.org/en-US/docs/Web/Events
Event Handlersto be notified when an event occurs, such as when a tag is clicked, you can specify an event
handler for the object.Specify the method:1. Use an HTML attribute with the element name On{eventtype}, for example:
<onclick= "return Handleclick (event);" >
2. Select an element with JavaScript and set the corresponding OnXxx attribute, for example:
function (event) {...}.
a more modern browser can be used with the
AddEventListener () method: https://developer.mozilla.org/en-US/docs/Web/API/ Eventtarget/addeventlistener However, this method is not compatible with IE9 before the browser.If you use jquery to register for monitoring, the framework will help us deal with browser compatibility issues.specific types of registration monitoring methods, the last blog post has a summary: http://www.cnblogs.com/mengdd/p/4354339.html event handler can be set on HTML elements or on other objects that generate events, such as
window,
document,
XMLHttpRequest and so on. for historical reasons, some <body> and <frameset> properties actually set the event handler on their window object.For example:onblur, OnError, onfocus, onload, onscroll.
Event Objectwhen the time is triggered, the callback method receives an event object as a parameter.So when you're dealing with it, you know what the current event (type) is, its target, and the associated event arguments.an event is an interface that has some common properties and methods.A variety of specific event interfaces (such as MouseEvent, KeyboardEvent) are subclasses of the event. event Attribute list: Https://developer.mozilla.org/en-US/docs/Web/API/Event#Properties in the method of the event object:
event.stoppropagation () prevents further propagation of the current event.
Event.preventdefault () cancels events that can be canceled, but does not prevent further propagation of the event.
preventdefault () is used to prevent some default behavior from occurring. References:doc:https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/dom3-events.htmlEvent Developer guide:https://developer.mozilla.org/en-us/docs/web/guide/eventsLearn JQuery events:http://learn.jquery.com/events/Mozilla Event reference:https://developer.mozilla.org/en-us/docs/web/eventsEvent handler:https://developer.mozilla.org/en-us/docs/web/guide/events/event_handlers
Blog post: http://chajn.org/project/javascript-events-responding-user/
[DOM Event Learning] Section 2 concept comb what is event DOM events