草案
本页尚未完工.
事件(Event)是指一种用于处理在网页的生命周期中发生的各种事件的异步调用的设计模式,也指一些不同种类事件的命名、描述和使用。
在 概述 中提供了对设计模式的介绍和现代Web浏览器中事件和处理程序的概述。
在 自定义事件 中介绍了如何创建自定义事件、注册监听自定义事件和如何在代码中触发自定义事件
接下来的内容描述了如何在Web浏览器中使用不同类型的事件。不幸的是,这些事件是随着Web浏览器的发展逐一定义的,所以,目前还没有一个令人满意的系统描述。
设备可以在Web浏览器运行时触发事件, for example due to a change in its position and orientation in the real world, as discussed partially by the page on orientation coordinate systems and the page on the use of 3D transforms. That is different, but similar, to the change in device vertical orientation.
The 窗口 in which the browser is displayed which might trigger events, for example, change size if the user maximizes the window or otherwise changes it.
The process loading of a web page might trigger events in response to the completion of different steps in the downloading, parsing, and rendering of the web page for display to the user.
The user interaction with the web page contents might trigger events. The events triggered by user interaction evolved during the early years of browser design and include a complicated system defining the sequence in which events will be called and the manner in which that sequence can be controlled. The different types of user interaction driven events include:
- the original 'click' event,
- mouse events,
- mouse gesture events, and
- both touch events and the earlier, but deprecated, mozilla experimental touch events.
The modification of the web page in structure or content might trigger some events, as is explained in the mutation events page, but the use of these events has been deprecated in favour of the lighter Mutation Observer approach.
The media streams embedded in the HTML documents might trigger some events, as explained in the media events page.
The network requests made by a web page might trigger some events.
There are many other sources of events defined by web browsers for which pages are not yet available in this guide.
Note: This Event Developer Guide needs substantial work. The structure needs to be reorganized and the pages rewritten. Our hope is that everything you need to know about events will go under here.
Docs
- DOM 事件回调
- Web平台提供了多种方式来获取 DOM events 的通知。种常见的风格是:广义
addEventListener()
和一组特定的on-event处理程序。本页重点介绍后者如何工作的细节。 - Mutation events
- Mutation events provide a mechanism for a web page or an extension to get notified about changes made to the DOM. Use Mutation Observers instead if possible.
- Orientation 和 motion 数据解释
- 当我们要使用orientation和motion事件时,理解浏览器给我们的相关值是什么意思就显的相当重要了。这篇文章会详细介绍在用的坐标系统并会教你如何全用它们。
- Overview of Events and Handlers
- Events and event handling provide a core technique in Javascript for reactivity to incidents which occur during the time a web page is kept open by a user, including incidents which occur while a page is being prepared for display, incidents due to user interaction with the content of the web page, incidents related to the device on which the browser is running, or incidents due to many other causes such as media stream playback or animation timing.
- 创建和触发 events
- 本文演示了如何创建和分派DOM事件。这些事件通常称为合成事件,而不是浏览器本身触发的事件。
- 媒体相关事件
- 在处理用
<audio>
和<video>
标签嵌入到HTML文档中的媒体时,会触发多种事件。本章列出这些事件,并给出一些使用方法。