diff --git a/files/zh-cn/web/demos/index.html b/files/zh-cn/web/demos/index.html deleted file mode 100644 index cf0c051e4e3d6f..00000000000000 --- a/files/zh-cn/web/demos/index.html +++ /dev/null @@ -1,155 +0,0 @@ ---- -title: 开源 Web 技术示例 -slug: Web/Demos -tags: - - 2D - - 3D - - CSS - - Canvas - - Design - - HTML - - SVG - - Video -translation_of: Web/Demos_of_open_web_technologies -original_slug: Web/Demos_of_open_web_technologies ---- -

Mozilla 支持各种令人兴奋的开源 Web 技术,我们鼓励大家使用它们。此页面提供了有关这些技术的一些有趣演示链接。

- -

如果你知道开源 Web 技术的优秀演示或者应用,就在这里(以及 英文页面)添加一个合适的链接吧。

- -

2D 图形

- -

Canvas

- - - -

SVG

- - - -

视频

- - - -

3D 图像

- -

WebGL

- - - -

虚拟现实(VR)

- - - -

CSS

- - - -

旧项目:

- - - -

变换

- - - -

游戏

- - - -

Web API

- - - -

通知 API

- - - - - -

网络音频 API

- - - -

文件 API

- - - -

其他

- - diff --git a/files/zh-cn/web/demos/index.md b/files/zh-cn/web/demos/index.md new file mode 100644 index 00000000000000..58c867a5aec875 --- /dev/null +++ b/files/zh-cn/web/demos/index.md @@ -0,0 +1,123 @@ +--- +title: 开源 Web 技术示例 +slug: Web/Demos +tags: + - 2D + - 3D + - CSS + - Canvas + - Design + - HTML + - SVG + - Video +translation_of: Web/Demos_of_open_web_technologies +original_slug: Web/Demos_of_open_web_technologies +--- +Mozilla 支持各种令人兴奋的开源 Web 技术,我们鼓励大家使用它们。此页面提供了有关这些技术的一些有趣演示链接。 + +如果你知道开源 Web 技术的优秀演示或者应用,就在这里(以及 [英文页面](/en-US/docs/Web/Demos_of_open_web_technologies))添加一个合适的链接吧。 + +## 2D 图形 + +### Canvas + +- [Blob Sallad: an interactive blob using JavaScript and canvas](http://www.blobsallad.se/)([示例](http://blobsallad.se/article/)) +- [Flying through space](http://arapehlivanian.com/wp-content/uploads/2007/02/canvas.html) +- [3D RayCaster](/samples/raycaster/RayCaster.html) +- [processing.js](http://processingjs.org/exhibition/) +- [3D on 2D Canvas](http://gyu.que.jp/jscloth/) +- [miniPaint: Image editor](http://viliusle.github.io/miniPaint/)([源码](https://github.com/viliusle/miniPaint)) +- [Zen Photon Garden](http://zenphoton.com/)([源码](https://github.com/scanlime/zenphoton)) + +### SVG + +- [Bubblemenu](http://starkravingfinkle.org/projects/demo/svg-bubblemenu-in-html.xml) (视觉特效与交互) +- [HTML transformations](http://starkravingfinkle.org/blog/2007/07/firefox-3-svg-foreignobject/)(使用了 `` 元素)(视觉特效与变换) +- [Phonetics Guide](http://svg-whiz.com/svg/linguistics/theCreepyMouth.svg)(可交互) +- [3D objects demo](http://www.lutanho.net/svgvml3d/platonic.html)(可交互) +- [Blobular](http://www.themaninblue.com/experiment/Blobular/)(可交互) +- [Video embedded in SVG](http://www.double.co.nz/video_test/video.svg)(或[下载到本地](http://www.double.co.nz/video_test/video_svg.tar.bz2)) +- [Summer HTML image map creator](http://summerstyle.github.io/summer/)([源码](https://github.com/summerstyle/summer)) + +### 视频 + +- [Video 3D Animation "mozilla constantly evolving"](https://vimeo.com/172328210) +- [Video 3D animation "Floating Dance"](https://vimeo.com/173851395) +- [Streaming Anime, Movie Trailer and Interview](http://www.double.co.nz/video_test/test1.html) +- [Billy's Browser Firefox Flick](http://www.double.co.nz/video_test/test2.html) +- [Virtual Barber Shop](http://www.double.co.nz/video_test/test3.html) +- [Transformers Movie Trailer](http://www.double.co.nz/video_test/test4.html) +- [A Scanner Darkly Movie Trailer](http://www.double.co.nz/video_test/test5.html)(自带控制功能) +- [Events firing and volume control](http://www.double.co.nz/video_test/events.html) +- [Dragable and sizable videos](http://www.double.co.nz/video_test/video.svg) + +## 3D 图像 + +### WebGL + +- [Web Audio Fireworks](http://ondras.github.io/fireworks-webgl/) +- IoQuake3([源码](https://github.com/klaussilveira/ioquake3.js)) +- Escher puzzle([源码](https://github.com/micahbolen/demoscene)) +- [Kai 'Opua](http://collinhover.github.io/kaiopua/)([源码](https://github.com/collinhover/kaiopua)) + +### 虚拟现实(VR) + +- [The Polar Sea](http://mozvr.com/demos/polarsea/)([源码](https://github.com/MozVR/polarsea)) +- [Sechelt fly-through](http://mozvr.github.io/sechelt/)([源码](https://github.com/mozvr/sechelt)) + +## CSS + +- [CSS Zen Garden](http://www.csszengarden.com/) +- [CSS floating logo "mozilla"](https://codepen.io/SoftwareRVG/pen/OXkOWj/) +- [Paperfold](http://felixniklas.com/paperfold/) +- [CSS Blockout](http://ondras.github.io/blockout/) +- [Rubik's cube](http://ondras.zarovi.cz/demos/rubik/) +- [Pure CSS Slides](http://ondras.zarovi.cz/demos/nojs/) +- Planetarium([源码](https://github.com/littleworkshop/planetarium)) +- [Loader with blend modes](https://codepen.io/equinusocio/full/qjyXPP/) +- [Text reveal with clip-path](https://codepen.io/equinusocio/full/KNYOxJ/) +- [Ambient shadow with custom properties](https://codepen.io/equinusocio/full/GvyvWd/) +- [Luminiscent vial](https://codepen.io/equinusocio/full/jEVNeJ/) + +旧项目: + +- [CSS floating logo "Mozilla" developed by Rober Villar, from Software RVG. ](https://s.codepen.io/SoftwareRVG/debug/OXkOWj)(debug 模式) +- [Bootstrap Contact Form Design](https://webdeveloperbareilly.in/blog/html5/responsive-contact-form-bootstrap.php) +- [CSS Paralax Forest](http://www.lesmoffat.co.uk/folio/forest/forest.html) +- [Responsive Login Page Design](http://webdeveloperbareilly.in/blog/css3/awesome-login-form.html) +- [One Page Scroll Website Template](http://webdeveloperbareilly.in/blog/css3/onepage-scroll-template.html) + +### 变换 + +- [Impress.js](http://impress.github.io/impress.js) ([源码](https://github.com/impress/impress.js)) + +## 游戏 + +- IoQuake3([源码](https://github.com/klaussilveira/ioquake3.js)) +- [Kai 'Opua](http://collinhover.github.io/kaiopua/)([源码](https://github.com/collinhover/kaiopua)) + +## Web API + +### 通知 API + +- [HTML5 Notifications](http://elfoxero.github.io/html5notifications/)([源码](https://github.com/elfoxero/html5notifications)) + +### 网络音频 API + +- [Web Audio Fireworks](http://ondras.github.io/fireworks-webgl/) +- [oscope.js - JavaScript oscilloscope](http://ondras.github.io/oscope/) +- [HTML5 Web Audio Showcase](http://nipe-systems.de/webapps/html5-web-audio/)([源码](https://github.com/NIPE-SYSTEMS/html5-web-audio-showcase)) +- [HTML5 Audio Visualizer](http://wayou.github.io/HTML5_Audio_Visualizer/)([源码](https://github.com/Wayou/HTML5_Audio_Visualizer)) +- [Graphical Filter Editor and Visualizer](http://carlosrafaelgn.com.br/GraphicalFilterEditor/)([源码](https://github.com/carlosrafaelgn/GraphicalFilterEditor)) + +### 文件 API + +- [Slide My Text - presentation from plain text files](http://palerdot.github.io/slide-my-text/) + +### 其他 + +- [Web Worker Fractals](http://ondras.github.io/fractal/) +- [Photo editor](http://ondras.github.io/photo/) +- [Coral generator](http://ondras.github.io/coral/) +- [Raytracer](http://nerget.com/rayjs-mt/rayjs.html) +- [HotCold Touch Typing](http://palerdot.github.io/hotcold/) diff --git a/files/zh-cn/web/events/creating_and_triggering_events/index.html b/files/zh-cn/web/events/creating_and_triggering_events/index.html deleted file mode 100644 index 44d8aad87b5b10..00000000000000 --- a/files/zh-cn/web/events/creating_and_triggering_events/index.html +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: 创建和触发 events -slug: Web/Events/Creating_and_triggering_events -translation_of: Web/Events/Creating_and_triggering_events -tags: - - Advanced - - DOM - - Guide - - JavaScript - - NeedsContent - - events ---- -

本文演示了如何创建和分派 DOM 事件。这些事件通常称为合成事件,而不是浏览器本身触发的事件。

- -

创建自定义事件

- -

Events 可以使用 Event 构造函数创建如下:

- -
var event = new Event('build');
-
-// Listen for the event.
-elem.addEventListener('build', function (e) { ... }, false);
-
-// Dispatch the event.
-elem.dispatchEvent(event);
- -

上述代码使用了 EventTarget.dispatchEvent() 方法。

- -

绝大多数现代浏览器中都会支持这个构造函数(Internet Explorer 例外)。 要了解更为复杂的方法,可参考下面的 过时的方式 一节。

- -

添加自定义数据 – CustomEvent()

- -

要向事件对象添加更多数据,可以使用 CustomEvent 接口,detail 属性可用于传递自定义数据。
- 例如,event 可以创建如下:

- -
var event = new CustomEvent('build', { 'detail': elem.dataset.time });
- -

下面的代码允许你在事件监听器中访问更多的数据:

- -
function eventHandler(e) {
-  log('The time is: ' + e.detail);
-}
-
- -

过时的方式

- -

早期的创建事件的方法使用了受 Java 启发的 API。下面展示了一个示例:

- -
// Create the event.
-var event = document.createEvent('Event');
-
-// Define that the event name is 'build'.
-event.initEvent('build', true, true);
-
-// Listen for the event.
-document.addEventListener('build', function (e) {
-  // e.target matches document from above
-}, false);
-
-// target can be any Element or other EventTarget.
-document.dispatchEvent(event);
-
- -

事件冒泡

- -

通常需要从子元素触发事件,并让祖先捕获它:

- -
<form>
-  <textarea></textarea>
-</form>
- -
const form = document.querySelector('form');
-const textarea = document.querySelector('textarea');
-
-// Create a new event, allow bubbling, and provide any data you want to pass to the "details" property
-const eventAwesome = new CustomEvent('awesome', {
-  bubbles: true,
-  detail: { text: () => textarea.value }
-});
-
-// The form element listens for the custom "awesome" event and then consoles the output of the passed text() method
-form.addEventListener('awesome', e => console.log(e.detail.text()));
-
-// As the user types, the textarea inside the form dispatches/triggers the event to fire, and uses itself as the starting point
-textarea.addEventListener('input', e => e.target.dispatchEvent(eventAwesome));
- -

动态创建和派发事件

- -

元素可以侦听尚未创建的事件:

- -
<form>
-  <textarea></textarea>
-</form>
- -
const form = document.querySelector('form');
-const textarea = document.querySelector('textarea');
-
-form.addEventListener('awesome', e => console.log(e.detail.text()));
-
-textarea.addEventListener('input', function() {
-  // Create and dispatch/trigger an event on the fly
-  // Note: Optionally, we've also leveraged the "function expression" (instead of the "arrow function expression") so "this" will represent the element
-  this.dispatchEvent(new CustomEvent('awesome', { bubbles: true, detail: { text: () => textarea.value } }))
-});
- - - -

触发内置事件

- -

下面的例子演示了一个在复选框上点击(click)的模拟(就是说在程序里生成一个 click 事件),这个模拟点击使用了 DOM 方法。参见这个动态示例

- -
function simulateClick() {
-  var event = new MouseEvent('click', {
-    'view': window,
-    'bubbles': true,
-    'cancelable': true
-  });
-  var cb = document.getElementById('checkbox');
-  var cancelled = !cb.dispatchEvent(event);
-  if (cancelled) {
-    // A handler called preventDefault.
-    alert("cancelled");
-  } else {
-    // None of the handlers called preventDefault.
-    alert("not cancelled");
-  }
-}
-
- -

参见

- - diff --git a/files/zh-cn/web/events/creating_and_triggering_events/index.md b/files/zh-cn/web/events/creating_and_triggering_events/index.md new file mode 100644 index 00000000000000..5c06178ba69025 --- /dev/null +++ b/files/zh-cn/web/events/creating_and_triggering_events/index.md @@ -0,0 +1,149 @@ +--- +title: 创建和触发 events +slug: Web/Events/Creating_and_triggering_events +tags: + - Advanced + - DOM + - Guide + - JavaScript + - NeedsContent + - events +translation_of: Web/Events/Creating_and_triggering_events +--- +本文演示了如何创建和分派 DOM 事件。这些事件通常称为**合成事件**,而不是浏览器本身触发的事件。 + +## 创建自定义事件 + +Events 可以使用 [`Event`](/zh/docs/Web/API/Event) 构造函数创建如下: + +```js +var event = new Event('build'); + +// Listen for the event. +elem.addEventListener('build', function (e) { ... }, false); + +// Dispatch the event. +elem.dispatchEvent(event); +``` + +上述代码使用了 [EventTarget.dispatchEvent()](/zh-CN/docs/Web/API/EventTarget/dispatchEvent) 方法。 + +绝大多数现代浏览器中都会支持这个构造函数(Internet Explorer 例外)。 要了解更为复杂的方法,可参考下面的 [过时的方式](#The_old-fashioned_way) 一节。 + +### 添加自定义数据 – CustomEvent() + +要向事件对象添加更多数据,可以使用 [CustomEvent](/zh-CN/docs/Web/API/CustomEvent) 接口,detail 属性可用于传递自定义数据。 +例如,event 可以创建如下: + +```js +var event = new CustomEvent('build', { 'detail': elem.dataset.time }); +``` + +下面的代码允许你在事件监听器中访问更多的数据: + +```js +function eventHandler(e) { + log('The time is: ' + e.detail); +} +``` + +### 过时的方式 + +早期的创建事件的方法使用了受 Java 启发的 API。下面展示了一个示例: + +```js +// Create the event. +var event = document.createEvent('Event'); + +// Define that the event name is 'build'. +event.initEvent('build', true, true); + +// Listen for the event. +document.addEventListener('build', function (e) { + // e.target matches document from above +}, false); + +// target can be any Element or other EventTarget. +document.dispatchEvent(event); +``` + +### 事件冒泡 + +通常需要从子元素触发事件,并让祖先捕获它: + +```html +
+ +
+``` + +```js +const form = document.querySelector('form'); +const textarea = document.querySelector('textarea'); + +// Create a new event, allow bubbling, and provide any data you want to pass to the "details" property +const eventAwesome = new CustomEvent('awesome', { + bubbles: true, + detail: { text: () => textarea.value } +}); + +// The form element listens for the custom "awesome" event and then consoles the output of the passed text() method +form.addEventListener('awesome', e => console.log(e.detail.text())); + +// As the user types, the textarea inside the form dispatches/triggers the event to fire, and uses itself as the starting point +textarea.addEventListener('input', e => e.target.dispatchEvent(eventAwesome)); +``` + +### 动态创建和派发事件 + +元素可以侦听尚未创建的事件: + +```html +
+ +
+``` + +```js +const form = document.querySelector('form'); +const textarea = document.querySelector('textarea'); + +form.addEventListener('awesome', e => console.log(e.detail.text())); + +textarea.addEventListener('input', function() { + // Create and dispatch/trigger an event on the fly + // Note: Optionally, we've also leveraged the "function expression" (instead of the "arrow function expression") so "this" will represent the element + this.dispatchEvent(new CustomEvent('awesome', { bubbles: true, detail: { text: () => textarea.value } })) +}); +``` + +## 触发内置事件 + +下面的例子演示了一个在复选框上点击(click)的模拟(就是说在程序里生成一个 click 事件),这个模拟点击使用了 DOM 方法。[参见这个动态示例](/samples/domref/dispatchEvent.html) + +```js +function simulateClick() { + var event = new MouseEvent('click', { + 'view': window, + 'bubbles': true, + 'cancelable': true + }); + var cb = document.getElementById('checkbox'); + var cancelled = !cb.dispatchEvent(event); + if (cancelled) { + // A handler called preventDefault. + alert("cancelled"); + } else { + // None of the handlers called preventDefault. + alert("not cancelled"); + } +} +``` + +## 参见 + +- [CustomEvent()](/en-US/docs/Web/API/CustomEvent/CustomEvent) +- {{domxref("document.createEvent()")}} +- {{domxref("Event.initEvent()")}} +- {{domxref("EventTarget.dispatchEvent()")}} +- {{domxref("EventTarget.addEventListener()")}} diff --git a/files/zh-cn/web/events/detecting_device_orientation/index.html b/files/zh-cn/web/events/detecting_device_orientation/index.html deleted file mode 100644 index f8c27eaf51cae8..00000000000000 --- a/files/zh-cn/web/events/detecting_device_orientation/index.html +++ /dev/null @@ -1,296 +0,0 @@ ---- -title: 检测设备方向 -slug: Web/Events/Detecting_device_orientation -translation_of: Web/Events/Detecting_device_orientation -tags: - - API - - Device Orientation - - Intermediate - - Mobile - - Motion - - Orientation - - Reference ---- -

{{SeeCompatTable}}

- -

有越来越多的基于 web 的设备能够确定它们的方向; 也就是说,它们可以报告数据以指示基于重力方向的方向改变。特别地,手持设备如手机可以利用这些信息以自动旋转屏幕,保持内容直立,当设备旋转至横屏时(宽度大于高度),提供网页内容的横屏视图。

- -

有两种 Javascript 事件负责处理设备方向信息。第一种是{{domxref("DeviceOrientationEvent")}},它会在加速度传感器检测到设备在方向上产生变化时触发。通过处理该事件传来的数据信息,让交互式地响应用户移动设备旋转和仰角变化成为可能。

- -

第二种是{{domxref("DeviceMotionEvent")}},它会在加速度发生改变时触发。跟{{domxref("DeviceOrientationEvent")}}不同,{{domxref("DeviceMotionEvent")}}监听的是相应方向上加速度的变化。传感器通常都具有监听{{domxref("DeviceMotionEvent")}}的能力,包括笔记本中用于保护移动中的存储设备的传感器。{{domxref("DeviceOrientationEvent")}}事件更多见于移动设备中。

- -

处理方向(orientation)事件

- -

要接收设备方向变化信息,只需要监听{{ event("deviceorientation") }}事件:

- -
-

注意:gyronorm.js is a polyfill for normalizing the accelerometer and gyroscope data on mobile devices. This is useful for overcoming some of the differences in device support for device orientation.

-
- -
window.addEventListener("deviceorientation", handleOrientation, true);
-
- -

注册完事件监听处理函数后(对应这个例子中的 handleOrientation),监听函数会定期地接收到最新的设备方向数据。

- -

方向事件对象中包含四个值:

- -

{{ domxref("DeviceOrientationEvent.absolute") }}

- -

{{ domxref("DeviceOrientationEvent.alpha") }}

- -

{{ domxref("DeviceOrientationEvent.beta") }}

- -

{{ domxref("DeviceOrientationEvent.gamma") }}

- -

下面是一个事件处理函数的例子:

- -
function handleOrientation(orientData) {
-  var absolute = orientData.absolute;
-  var alpha = orientData.alpha;
-  var beta = orientData.beta;
-  var gamma = orientData.gamma;
-
-  // Do stuff with the new orientation data
-}
-
- -

相关值解释

- -

关于每一个轴的记录值表示的是相对于标准的坐标系,设备在某一个给定轴上的旋转量。Orientation and motion data explained 这篇文章有更详细的描述,下面是对这篇文章的总结。

- - - -

例子

- -

这个例子会成功运行在支持检测自己方向的设备中的支持{{event("deviceorientation")}} 事件的浏览器中。

- -

让我们想象一下有一个球在花园中:

- -
<div class="garden">
-  <div class="ball"></div>
-</div>
-
-<pre class="output"></pre>
- -
- -
- -

花园只有 200px 宽(很小对吧),球在中央:

- -
.garden {
-  position: relative;
-  width : 200px;
-  height: 200px;
-  border: 5px solid #CCC;
-  border-radius: 10px;
-}
-
-.ball {
-  position: absolute;
-  top   : 90px;
-  left  : 90px;
-  width : 20px;
-  height: 20px;
-  background: green;
-  border-radius: 100%;
-}
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -

现在,如果我们移动设备,球将随之移动:

- -
var ball   = document.querySelector('.ball');
-var garden = document.querySelector('.garden');
-var output = document.querySelector('.output');
-
-var maxX = garden.clientWidth  - ball.clientWidth;
-var maxY = garden.clientHeight - ball.clientHeight;
-
-function handleOrientation(event) {
-  var x = event.beta;  // In degree in the range [-180,180]
-  var y = event.gamma; // In degree in the range [-90,90]
-
-  output.innerHTML  = "beta : " + x + "\n";
-  output.innerHTML += "gamma: " + y + "\n";
-
-  // Because we don't want to have the device upside down
-  // We constrain the x value to the range [-90,90]
-  if (x >  90) { x =  90};
-  if (x < -90) { x = -90};
-
-  // To make computation easier we shift the range of
-  // x and y to [0,180]
-  x += 90;
-  y += 90;
-
-  // 10 is half the size of the ball
-  // It center the positioning point to the center of the ball
-  ball.style.top  = (maxX*x/180 - 10) + "px";
-  ball.style.left = (maxY*y/180 - 10) + "px";
-}
-
-window.addEventListener('deviceorientation', handleOrientation);
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
-
- -
- -
- -
- -
- -
- -
- -
-
- -

输出结果:

- -

在{{LiveSampleLink("Orientation_example", "这里")}}以新窗口打开此示例;因为有些浏览器中的 {{event("deviceorientation")}} 事件不支持跨域。

- -
{{EmbedLiveSample('Orientation_example', '230', '260')}}
- -
-

警告: Chrome 和 Firefox 处理角度的机制不同,所以某些轴上的方向是相反的。

-
- -

处理移动(motion)事件

- -

移动事件的处理跟方向事件是一样的,除了他们有自己的事件名:{{ event("devicemotion") }}

- -
window.addEventListener("devicemotion", handleMotion, true);
- -
- -

真正不同的是做为参数传递给HandleMotion 函数的{{ domxref("DeviceMotionEvent") }}对象所包含的信息。

- -

这个对象包含四个属性:

- - - -

相关值解释

- -

{{ domxref("DeviceMotionEvent") }}对象提供给 web 开发者设备在位置和方向上的改变速度的相关信息。这些变化信息是通过三个轴来体现的。(Orientation and motion data explained有更详细的说明。)

- -

accelerationaccelerationIncludingGravity,都包含下面三个轴:

- - - -

对于 rotationRate ,情况有点不同;三个轴的信息对应着以下三种情况:

- - - -

最后,interval 表示的是从设备获取数据的间隔时间,单位是毫秒。

- -

规范

- -{{Specifications}} - -

浏览器兼容性

- -{{Compat}} - -

参见

- - diff --git a/files/zh-cn/web/events/detecting_device_orientation/index.md b/files/zh-cn/web/events/detecting_device_orientation/index.md new file mode 100644 index 00000000000000..b19ec5581c9d28 --- /dev/null +++ b/files/zh-cn/web/events/detecting_device_orientation/index.md @@ -0,0 +1,194 @@ +--- +title: 检测设备方向 +slug: Web/Events/Detecting_device_orientation +tags: + - API + - Device Orientation + - Intermediate + - Mobile + - Motion + - Orientation + - Reference +translation_of: Web/Events/Detecting_device_orientation +--- +{{SeeCompatTable}} + +有越来越多的基于 web 的设备能够确定它们的方向; 也就是说,它们可以报告数据以指示基于重力方向的方向改变。特别地,手持设备如手机可以利用这些信息以自动旋转屏幕,保持内容直立,当设备旋转至横屏时(宽度大于高度),提供网页内容的横屏视图。 + +有两种 Javascript 事件负责处理设备方向信息。第一种是{{domxref("DeviceOrientationEvent")}},它会在加速度传感器检测到设备在方向上产生变化时触发。通过处理该事件传来的数据信息,让交互式地响应用户移动设备旋转和仰角变化成为可能。 + +第二种是{{domxref("DeviceMotionEvent")}},它会在加速度发生改变时触发。跟{{domxref("DeviceOrientationEvent")}}不同,{{domxref("DeviceMotionEvent")}}监听的是相应方向上加速度的变化。传感器通常都具有监听{{domxref("DeviceMotionEvent")}}的能力,包括笔记本中用于保护移动中的存储设备的传感器。{{domxref("DeviceOrientationEvent")}}事件更多见于移动设备中。 + +## 处理方向(orientation)事件 + +要接收设备方向变化信息,只需要监听{{ event("deviceorientation") }}事件: + +> **备注:** [gyronorm.js](https://github.com/dorukeker/gyronorm.js) is a polyfill for normalizing the accelerometer and gyroscope data on mobile devices. This is useful for overcoming some of the differences in device support for device orientation. + +```js +window.addEventListener("deviceorientation", handleOrientation, true); +``` + +注册完事件监听处理函数后(对应这个例子中的 handleOrientation),监听函数会定期地接收到最新的设备方向数据。 + +方向事件对象中包含四个值: + +{{ domxref("DeviceOrientationEvent.absolute") }} + +{{ domxref("DeviceOrientationEvent.alpha") }} + +{{ domxref("DeviceOrientationEvent.beta") }} + +{{ domxref("DeviceOrientationEvent.gamma") }} + +下面是一个事件处理函数的例子: + +```js +function handleOrientation(orientData) { + var absolute = orientData.absolute; + var alpha = orientData.alpha; + var beta = orientData.beta; + var gamma = orientData.gamma; + + // Do stuff with the new orientation data +} +``` + +### 相关值解释 + +关于每一个轴的记录值表示的是相对于标准的坐标系,设备在某一个给定轴上的旋转量。[Orientation and motion data explained](/en-US/DOM/Orientation_and_motion_data_explained) 这篇文章有更详细的描述,下面是对这篇文章的总结。 + +- {{ domxref("DeviceOrientationEvent.alpha") }} 表示设备沿 z 轴上的旋转角度,范围为 0\~360。 +- {{ domxref("DeviceOrientationEvent.beta") }} 表示设备在 x 轴上的旋转角度,范围为-180\~180。它描述的是设备由前向后旋转的情况。 +- {{ domxref("DeviceOrientationEvent.gamma") }} 表示设备在 y 轴上的旋转角度,范围为-90\~90。它描述的是设备由左向右旋转的情况。 + +### 例子 + +这个例子会成功运行在支持检测自己方向的设备中的支持{{event("deviceorientation")}} 事件的浏览器中。 + +让我们想象一下有一个球在花园中: + +```html +
+
+
+ +

+```
+
+花园只有 200px 宽(很小对吧),球在中央:
+
+```css
+.garden {
+  position: relative;
+  width : 200px;
+  height: 200px;
+  border: 5px solid #CCC;
+  border-radius: 10px;
+}
+
+.ball {
+  position: absolute;
+  top   : 90px;
+  left  : 90px;
+  width : 20px;
+  height: 20px;
+  background: green;
+  border-radius: 100%;
+}
+```
+
+现在,如果我们移动设备,球将随之移动:
+
+```js
+var ball   = document.querySelector('.ball');
+var garden = document.querySelector('.garden');
+var output = document.querySelector('.output');
+
+var maxX = garden.clientWidth  - ball.clientWidth;
+var maxY = garden.clientHeight - ball.clientHeight;
+
+function handleOrientation(event) {
+  var x = event.beta;  // In degree in the range [-180,180]
+  var y = event.gamma; // In degree in the range [-90,90]
+
+  output.innerHTML  = "beta : " + x + "\n";
+  output.innerHTML += "gamma: " + y + "\n";
+
+  // Because we don't want to have the device upside down
+  // We constrain the x value to the range [-90,90]
+  if (x >  90) { x =  90};
+  if (x < -90) { x = -90};
+
+  // To make computation easier we shift the range of
+  // x and y to [0,180]
+  x += 90;
+  y += 90;
+
+  // 10 is half the size of the ball
+  // It center the positioning point to the center of the ball
+  ball.style.top  = (maxX*x/180 - 10) + "px";
+  ball.style.left = (maxY*y/180 - 10) + "px";
+}
+
+window.addEventListener('deviceorientation', handleOrientation);
+```
+
+输出结果:
+
+在{{LiveSampleLink("Orientation_example", "这里")}}以新窗口打开此示例;因为有些浏览器中的 {{event("deviceorientation")}} 事件不支持跨域。
+
+{{EmbedLiveSample('Orientation_example', '230', '260')}}
+
+> **警告:** Chrome 和 Firefox 处理角度的机制不同,所以某些轴上的方向是相反的。
+
+## 处理移动(motion)事件
+
+移动事件的处理跟方向事件是一样的,除了他们有自己的事件名:{{ event("devicemotion") }}
+
+```js
+window.addEventListener("devicemotion", handleMotion, true);
+```
+
+真正不同的是做为参数传递给*HandleMotion 函数的*{{ domxref("DeviceMotionEvent") }}对象所包含的信息。
+
+这个对象包含四个属性:
+
+- {{ domxref("DeviceMotionEvent.acceleration") }}
+- {{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }}
+- {{ domxref("DeviceMotionEvent.rotationRate") }}
+- {{ domxref("DeviceMotionEvent.interval") }}
+
+### 相关值解释
+
+{{ domxref("DeviceMotionEvent") }}对象提供给 web 开发者设备在位置和方向上的改变速度的相关信息。这些变化信息是通过三个轴来体现的。([Orientation and motion data explained](/en-US/docs/Web/Guide/DOM/Events/Orientation_and_motion_data_explained)有更详细的说明。)
+
+[`acceleration`](/en-US/docs/Web/API/DeviceMotionEvent.acceleration) 和 [`accelerationIncludingGravity`](/en-US/docs/Web/API/DeviceMotionEvent.accelerationIncludingGravity),都包含下面三个轴:
+
+- `x`: 西向东
+- `y`: 南向北
+- `z`: 垂直地面
+
+对于 [`rotationRate`](/en-US/docs/Web/API/DeviceMotionEvent.rotationRate) ,情况有点不同;三个轴的信息对应着以下三种情况:
+
+- `alpha`: 设备沿着垂直于屏幕(对于桌面设备则是垂直于键盘)的轴的旋转速率
+- `beta`: 设备沿着屏幕(对于桌面设备则是键盘)左至右方向的轴的旋转速率 (桌面设备相对于键盘)
+- `gamma`: 设备沿着屏幕(对于桌面设备则是键盘)下至上方向的轴的旋转速率
+
+最后,[`interval`](/en-US/docs/Web/API/DeviceMotionEvent.interval) 表示的是从设备获取数据的间隔时间,单位是毫秒。
+
+## 规范
+
+{{Specifications}}
+
+## 浏览器兼容性
+
+{{Compat}}
+
+## 参见
+
+- {{domxref("DeviceOrientationEvent")}}
+- {{domxref("DeviceMotionEvent")}}
+- The legacy [`MozOrientation`](/en-US/DOM/MozOrientation) event.
+- [Orientation and motion data explained](/en-US/docs/Web/Guide/DOM/Events/Orientation_and_motion_data_explained)
+- [Using deviceorientation in 3D Transforms](/en-US/docs/Web/Guide/DOM/Events/Using_device_orientation_with_3D_transforms)
diff --git a/files/zh-cn/web/events/index.html b/files/zh-cn/web/events/index.html
deleted file mode 100644
index 0866cf9235450e..00000000000000
--- a/files/zh-cn/web/events/index.html
+++ /dev/null
@@ -1,2947 +0,0 @@
----
-title: 事件参考
-slug: Web/Events
-tags:
-  - Event
-  - Web
-  - 事件
-  - 参考
-  - 总览
-translation_of: Web/Events
----
-

发送 DOM 事件是为了将发生的相关事情通知代码。每个事件都是继承自{{DOMxRef("Event")}} 接口的对象,可以包括自定义的成员属性及函数用于获取事件发生时相关的更多信息。事件可以表示任何从基本的用户交互、到发生在渲染模型自动通知的任何事情。

- -

本文提供了一个可以发送的事件的列表;一些是官方标准中的标准事件,另一些则是在特定浏览器内部使用的事件;例如,列出的 Mozilla 特定事件,使附加组件可以借助它们与浏览器进行交互。

- -

最常见的类别

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

资源事件

-
事件名称何时触发
{{Event("error")}}资源加载失败时。
{{Event("abort")}}正在加载资源已经被中止时。
{{Event("load")}}资源及其相关资源已完成加载。
{{Event("beforeunload")}}window,document 及其资源即将被卸载。
{{Event("unload")}}文档或一个依赖资源正在被卸载。
- -

网络事件

- - - - - - - - - - - - - - - - - - -
事件名称何时触发
{{Event("online")}}浏览器已获得网络访问。
{{Event("offline")}}浏览器已失去网络访问。
- - - - - - - - - - - - - - - - - - - -
-

焦点事件

-
事件名称何时触发
{{Event("focus")}}元素获得焦点(不会冒泡)。
{{Event("blur")}}元素失去焦点(不会冒泡)。
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

WebSocket 事件

-
事件名称何时触发
openWebSocket 连接已建立。
message通过 WebSocket 接收到一条消息。
{{Event("error")}}WebSocket 连接异常被关闭(比如有些数据无法发送)。
closeWebSocket 连接已关闭。
- - - - - - - - - - - - - - - - - - - - - - - -
-

会话历史事件

-
事件名称何时触发
{{Event("pagehide")}}A session history entry is being traversed from.
{{Event("pageshow")}}A session history entry is being traversed to.
{{Event("popstate")}}A session history entry is being navigated to (in certain cases).
- - - - - - - - - - - - - - - - - - - - - - - -
-

CSS 动画事件

-
事件名称何时触发
{{Event("animationstart")}}某个 CSS 动画开始时触发。
{{Event("animationend")}}某个 CSS 动画完成时触发。
{{Event("animationiteration")}}某个 CSS 动画完成后重新开始时触发。
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

CSS 过渡事件

-
事件名称何时触发
{{Event("transitionstart")}}A CSS transition has actually started (fired after any delay).
{{Event("transitioncancel")}}CSS 过渡被取消
{{Event("transitionend")}}CSS 过渡已经完成
{{Event("transitionrun")}}A CSS transition has begun running (fired before any delay starts).
- - - - - - - - - - - - - - - - - - - -
-

表单事件

-
事件名称何时触发
{{Event("reset")}}点击重置按钮时
{{Event("submit")}}点击提交按钮
- - - - - - - - - - - - - - - - - - - -
-

打印事件

-
时间名称何时触发
{{Event("beforeprint")}}打印机已经就绪时触发
{{Event("afterprint")}}打印机关闭时触发
- - - - - - - - - - - - - - - - - - - - - - - -
-

文本写作事件

-
Event NameFired When
{{Event("compositionstart")}}The composition of a passage of text is prepared (similar to keydown for a keyboard input, but works with other inputs such as speech recognition).
{{Event("compositionupdate")}}A character is added to a passage of text being composed.
{{Event("compositionend")}}The composition of a passage of text has been completed or canceled.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

视图事件

-
Event NameFired When
{{Event("fullscreenchange")}}An element was turned to fullscreen mode or back to normal mode.
{{Event("fullscreenerror")}}It was impossible to switch to fullscreen mode for technical reasons or because the permission was denied.
{{Event("resize")}}The document view has been resized.
{{Event("scroll")}}The document view or an element has been scrolled.
- - - - - - - - - - - - - - - - - - - - - - - -
-

剪贴板事件

-
Event NameFired When
{{Event("cut")}}已经剪贴选中的文本内容并且复制到了剪贴板。
{{Event("copy")}}已经把选中的文本内容复制到了剪贴板。
{{Event("paste")}}从剪贴板复制的文本内容被粘贴。
- - - - - - - - - - - - - - - - - - - - - -
-

键盘事件

-
Event NameFired When
{{Event("keydown")}}按下任意按键。
{{Event("keypress")}}除 Shift、Fn、CapsLock 外的任意键被按住。(连续触发。)
{{Event("keyup")}}释放任意按键。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

鼠标事件

-
Event NameFired When
{{Event("auxclick")}}A pointing device button (ANY non-primary button) has been pressed and released on an element.
{{Event("click")}}在元素上按下并释放任意鼠标按键。
{{Event("contextmenu")}}右键点击(在右键菜单显示前触发)。
{{Event("dblclick")}}在元素上双击鼠标按钮。
{{Event("mousedown")}}在元素上按下任意鼠标按钮。
{{Event("mouseenter")}}指针移到有事件监听的元素内。
{{Event("mouseleave")}}指针移出元素范围外(不冒泡)。
{{Event("mousemove")}}指针在元素内移动时持续触发。
{{Event("mouseover")}}指针移到有事件监听的元素或者它的子元素内。
{{Event("mouseout")}}指针移出元素,或者移到它的子元素上。
{{Event("mouseup")}}在元素上释放任意鼠标按键。
{{Event("pointerlockchange")}}鼠标被锁定或者解除锁定发生时。
{{Event("pointerlockerror")}}可能因为一些技术的原因鼠标锁定被禁止时。
{{Event("select")}}有文本被选中。
{{Event("wheel")}}滚轮向任意方向滚动。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

拖放事件

-
Event NameFired When
{{Event("drag")}}正在拖动元素或文本选区(在此过程中持续触发,每 350ms 触发一次)
{{Event("dragend")}}拖放操作结束。(松开鼠标按钮或按下 Esc 键)
{{Event("dragenter")}}被拖动的元素或文本选区移入有效释放目标区
{{Event("dragstart")}}用户开始拖动 HTML 元素或选中的文本
{{Event("dragleave")}}被拖动的元素或文本选区移出有效释放目标区
{{Event("dragover")}}被拖动的元素或文本选区正在有效释放目标上被拖动(在此过程中持续触发,每 350ms 触发一次)
{{Event("drop")}}元素在有效释放目标区上释放
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

媒体事件

-
Event NameFired When
{{Event("audioprocess")}}The input buffer of a {{DOMxRef("ScriptProcessorNode")}} is ready to be processed.
{{Event("canplay")}}The browser can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.
{{Event("canplaythrough")}}The browser estimates it can play the media up to its end without stopping for content buffering.
{{Event("complete")}}The rendering of an {{DOMxRef("OfflineAudioContext")}} is terminated.
{{Event("durationchange")}}The duration attribute has been updated.
{{Event("emptied")}}The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.
{{Event("ended")}}Playback has stopped because the end of the media was reached.
{{Event("loadeddata")}}The first frame of the media has finished loading.
{{Event("loadedmetadata")}}The metadata has been loaded.
{{Event("pause")}}Playback has been paused.
{{Event("play")}}Playback has begun.
{{Event("playing")}}Playback is ready to start after having been paused or delayed due to lack of data.
{{Event("ratechange")}}The playback rate has changed.
{{Event("seeked")}}A seek operation completed.
{{Event("seeking")}}A seek operation began.
{{Event("stalled")}}The user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
{{Event("suspend")}}Media data loading has been suspended.
{{Event("timeupdate")}}The time indicated by the currentTime attribute has been updated.
{{Event("volumechange")}}The volume has changed.
{{Event("waiting")}}Playback has stopped because of a temporary lack of data.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

进度事件

-
Event NameFired When
abortProgression has been terminated (not due to an error).
{{Event("error")}}Progression has failed.
loadProgression has been successful.
{{Event("loadend")}}Progress has stopped (after "error", "abort" or "load" have been dispatched).
{{Event("loadstart")}}Progress has begun.
{{Event("progress")}}In progress.
{{Event("timeout")}}Progression is terminated due to preset time expiring.
- -

存储事件

- -

{{Event("change")}} (参见 非标准事件)
- {{Event("storage")}}

- -

更新事件

- -

{{Event("checking")}}
- {{Event("downloading")}}
- {{Event("error")}}
- {{Event("noupdate")}}
- {{Event("obsolete")}}
- {{Event("updateready")}}

- -

值变化事件

- -

{{Event("broadcast")}}
- {{Event("CheckboxStateChange")}}
- {{Event("hashchange")}}
- {{Event("input")}}
- {{Event("RadioStateChange")}}
- {{Event("readystatechange")}}
- {{Event("ValueChange")}}

- -

未分类的事件

- -

{{Event("invalid")}}
- message
- message
- open
- show

- -

不常见和非标准事件

- -

Abortable Fetch events

- - - - - - - - - - - - - - -
Event nameFired when
abortA DOM request is aborted, i.e. using {{DOMxRef("AbortController.abort()")}}.
- -

WebVR events

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event nameFired when
{{Event("vrdisplayactivate")}}When a VR display is able to be presented to, for example if an HMD has been moved to bring it out of standby, or woken up by being put on.
{{Event("vrdisplayblur")}}when presentation to a {{DOMxRef("VRDisplay")}} has been paused for some reason by the browser, OS, or VR hardware — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience.
{{Event("vrdisplayconnect")}}when a compatible {{DOMxRef("VRDisplay")}} is connected to the computer.
{{Event("vrdisplaydeactivate")}}When a {{DOMxRef("VRDisplay")}} can no longer be presented to, for example if an HMD has gone into standby or sleep mode due to a period of inactivity.
{{Event("vrdisplaydisconnect")}}When a compatible {{DOMxRef("VRDisplay")}} is disconnected from the computer.
{{Event("vrdisplayfocus")}}When presentation to a {{DOMxRef("VRDisplay")}} has resumed after being blurred.
{{Event("vrdisplaypresentchange")}}The presenting state of a {{DOMxRef("VRDisplay")}} changes — i.e. goes from presenting to not presenting, or vice versa.
- -

SVG 事件

- -

{{Event("SVGAbort")}}
- {{Event("SVGError")}}
- {{Event("SVGLoad")}}
- {{Event("SVGResize")}}
- {{Event("SVGScroll")}}
- {{Event("SVGUnload")}}
- {{Event("SVGZoom")}}

- -

数据库事件

- -

abort
- blocked
- complete
- {{Event("error")}}
- success
- upgradeneeded
- versionchange

- -

脚本事件

- -

{{Event("afterscriptexecute")}}
- {{Event("beforescriptexecute")}}

- -

菜单事件

- -

{{Event("DOMMenuItemActive")}}
- {{Event("DOMMenuItemInactive")}}

- -

窗口事件

- -

close

- -

弹出事件

- -

{{Event("popuphidden")}}
- {{Event("popuphiding")}}
- {{Event("popupshowing")}}
- {{Event("popupshown")}}

- -

Tab 事件

- -

{{Event("visibilitychange")}}

- - - -

电池事件

- -

{{Event("chargingchange")}}
- {{Event("chargingtimechange")}}
- {{Event("dischargingtimechange")}}
- {{Event("levelchange")}}

- -

呼叫事件

- -

{{Event("alerting")}}
- {{Event("busy")}}
- {{Event("callschanged")}}
- {{Event("cfstatechange")}}
- {{Event("connected")}}
- {{Event("connecting")}}
- {{Event("dialing")}}
- {{Event("disconnected")}}
- {{Event("disconnecting")}}
- {{Event("error_(Telephony)","error")}}
- {{Event("held")}}, {{Event("holding")}}
- {{Event("incoming")}}
- {{Event("resuming")}}
- {{Event("statechange")}}
- {{Event("voicechange")}}

- -

传感器事件

- -

{{Event("compassneedscalibration")}}
- {{Event("devicemotion")}}
- {{Event("deviceorientation")}}
- {{Event("orientationchange")}}

- -

智能卡事件

- -

{{Event("icccardlockerror")}}
- {{Event("iccinfochange")}}
- {{Event("smartcard-insert")}}
- {{Event("smartcard-remove")}}
- {{Event("stkcommand")}}
- {{Event("stksessionend")}}
- {{Event("cardstatechange")}}

- -

短信和 USSD 事件

- -

{{Event("delivered")}}
- {{Event("received")}}
- {{Event("sent")}}
- {{Event("ussdreceived")}}

- -

帧事件

- -

{{Event("mozbrowserclose")}}
- {{Event("mozbrowsercontextmenu")}}
- {{Event("mozbrowsererror")}}
- {{Event("mozbrowsericonchange")}}
- {{Event("mozbrowserlocationchange")}}
- {{Event("mozbrowserloadend")}}
- {{Event("mozbrowserloadstart")}}
- {{Event("mozbrowseropenwindow")}}
- {{Event("mozbrowsersecuritychange")}}
- {{Event("mozbrowsershowmodalprompt")}}
- {{Event("mozbrowsertitlechange")}}

- -

DOM 变异事件

- -

DOMAttributeNameChanged
- DOMAttrModified
- DOMCharacterDataModified
- {{Event("DOMContentLoaded")}}
- DOMElementNameChanged
- DOMNodeInserted
- DOMNodeInsertedIntoDocument
- DOMNodeRemoved
- DOMNodeRemovedFromDocument
- DOMSubtreeModified

- -

触摸事件

- -

{{Event("touchcancel")}}
- {{Event("touchend")}}
- {{Event("touchmove")}}
- {{Event("touchstart")}}

- -

指针事件

- -

{{Event("pointerover")}}
- {{Event("pointerenter")}}
- {{Event("pointerdown")}}
- {{Event("pointermove")}}
- {{Event("pointerup")}}
- {{Event("pointercancel")}}
- {{Event("pointerout")}}
- {{Event("pointerleave")}}
- {{Event("gotpointercapture")}}
- {{Event("lostpointercapture")}}

- -

标准事件

- -

这些事件在官方 Web 规范中定义,并且应在各个浏览器中通用。 每个事件都和代表事件接收方的对象(由此您可以查到每个事件提供的数据),定义这个事件的标准或标准链接会一起列出。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
事件名称事件类型规范触发时机...
{{Event("abort")}}{{DOMxRef("UIEvent")}}DOM L3资源载入已被中止
abort{{DOMxRef("ProgressEvent")}}ProgressandXMLHttpRequestProgress 被终止 (不是 error 造成的)
abort{{DOMxRef("Event")}}IndexedDB事务已被中止
{{Event("afterprint")}}{{DOMxRef("Event")}}HTML5相关文档已开始打印或打印预览已被关闭
{{Event("animationcancel")}}{{DOMxRef("AnimationEvent")}} {{Experimental_Inline}}CSS AnimationsA CSS animation has aborted.
{{Event("animationend")}}{{DOMxRef("AnimationEvent")}} {{Experimental_Inline}}CSS Animations完成一个CSS 动画
{{Event("animationiteration")}}{{DOMxRef("AnimationEvent")}} {{Experimental_Inline}}CSS Animations重复播放一个CSS 动画
{{Event("animationstart")}}{{DOMxRef("AnimationEvent")}} {{Experimental_Inline}}CSS Animations一个 CSS 动画已开始
{{Event("appinstalled")}}{{DOMxRef("Event")}}Web App ManifestA web application is successfully installed as a progressive web app.
{{Event("audioprocess")}}{{DOMxRef("AudioProcessingEvent")}} {{Deprecated_Inline}}{{SpecName('Web Audio API', '#AudioProcessingEvent', 'audioprocess')}}一个{{DOMxRef("ScriptProcessorNode")}} 的输入缓冲区可处理
{{Event("audioend")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}用户代理捕捉到用以语音识别的音频
{{Event("audiostart")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}用户代理开始捕捉用以语音识别的音频
{{Event("beforeprint")}}{{DOMxRef("Event")}}HTML5相关文档将要开始打印或准备打印预览
{{Event("beforeunload")}}{{DOMxRef("BeforeUnloadEvent")}}HTML5即将卸载 window,document 及其资源
{{Event("beginEvent")}}{{DOMxRef("TimeEvent")}}SVGA SMIL animation element begins.
blockedIndexedDBAn open connection to a database is blocking a versionchange transaction on the same database.
{{Event("blur")}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element has lost focus (does not bubble).
{{Event("boundary")}} {{Experimental_Inline}}{{DOMxRef("SpeechSynthesisEvent")}}{{SpecName('Web Speech API')}}The spoken utterance reaches a word or sentence boundary
{{Event("canplay")}}{{DOMxRef("Event")}}HTML5 mediaThe user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content.
{{Event("canplaythrough")}}{{DOMxRef("Event")}}HTML5 mediaThe user agent can play the media up to its end without having to stop for further buffering of content.
{{Event("change")}}{{DOMxRef("Event")}}DOM L2, HTML5The change event is fired for {{HTMLElement("input")}}, {{HTMLElement("select")}}, and {{HTMLElement("textarea")}} elements when a change to the element's value is committed by the user.
{{Event("chargingchange")}}{{DOMxRef("Event")}}Battery statusThe battery begins or stops charging.
{{Event("chargingtimechange")}}{{DOMxRef("Event")}}Battery statusThe chargingTime attribute has been updated.
{{Event("click")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device button has been pressed and released on an element.
close{{DOMxRef("Event")}}WebSocketA WebSocket connection has been closed.
completeIndexedDBA transaction successfully completed.
{{Event("complete")}}{{DOMxRef("OfflineAudioCompletionEvent")}} {{Deprecated_Inline}}{{SpecName('Web Audio API', '#OfflineAudioCompletionEvent-section', 'OfflineAudioCompletionEvent')}}The rendering of an {{DOMxRef("OfflineAudioContext")}} is terminated.
{{Event("compositionend")}}{{DOMxRef("CompositionEvent")}}DOM L3The composition of a passage of text has been completed or canceled.
{{Event("compositionstart")}}{{DOMxRef("CompositionEvent")}}DOM L3The composition of a passage of text is prepared (similar to keydown for a keyboard input, but works with other inputs such as speech recognition).
{{Event("compositionupdate")}}{{DOMxRef("CompositionEvent")}}DOM L3A character is added to a passage of text being composed.
{{Event("contextmenu")}}{{DOMxRef("MouseEvent")}}HTML5The right button of the mouse is clicked (before the context menu is displayed).
{{Event("copy")}}{{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}}ClipboardThe text selection has been added to the clipboard.
{{Event("cut")}}{{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}}ClipboardThe text selection has been removed from the document and added to the clipboard.
{{Event("dblclick")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device button is clicked twice on an element.
{{Event("devicechange")}}{{DOMxRef("Event")}}{{SpecName("Media Capture")}}A media device such as a camera, microphone, or speaker is connected or removed from the system.
{{Event("devicemotion")}}{{DOMxRef("DeviceMotionEvent")}} {{Experimental_Inline}}Device Orientation EventsFresh data is available from a motion sensor.
{{Event("deviceorientation")}}{{DOMxRef("DeviceOrientationEvent")}} {{Experimental_Inline}}Device Orientation EventsFresh data is available from an orientation sensor.
{{Event("dischargingtimechange")}}{{DOMxRef("Event")}}Battery statusThe dischargingTime attribute has been updated.
DOMActivate {{Deprecated_Inline}}{{DOMxRef("UIEvent")}}DOM L3A button, link or state changing element is activated (use {{Event("click")}} instead).
DOMAttributeNameChanged {{Deprecated_Inline}}{{DOMxRef("MutationNameEvent")}}DOM L3 RemovedThe name of an attribute changed (use mutation observers instead).
DOMAttrModified {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3The value of an attribute has been modified (use mutation observers instead).
DOMCharacterDataModified {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A text or another CharacterData has changed (use mutation observers instead).
{{Event("DOMContentLoaded")}}{{DOMxRef("Event")}}HTML5The document has finished loading (but not its dependent resources).
DOMElementNameChanged {{Deprecated_Inline}}{{DOMxRef("MutationNameEvent")}}DOM L3 RemovedThe name of an element changed (use mutation observers instead).
DOMFocusIn {{Deprecated_Inline}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element has received focus (use {{Event("focus")}} or {{Event("focusin")}} instead).
DOMFocusOut {{Deprecated_Inline}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element has lost focus (use {{Event("blur")}} or {{Event("focusout")}} instead).
DOMNodeInserted {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A node has been added as a child of another node (use mutation observers instead).
DOMNodeInsertedIntoDocument {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A node has been inserted into the document (use mutation observers instead).
DOMNodeRemoved {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A node has been removed from its parent node (use mutation observers instead).
DOMNodeRemovedFromDocument {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A node has been removed from the document (use mutation observers instead).
DOMSubtreeModified {{Deprecated_Inline}}{{DOMxRef("MutationEvent")}}DOM L3A change happened in the document (use mutation observers instead).
{{Event("drag")}}{{DOMxRef("DragEvent")}}HTML5An element or text selection is being dragged (every 350ms).
{{Event("dragend")}}{{DOMxRef("DragEvent")}}HTML5A drag operation is being ended (by releasing a mouse button or hitting the escape key).
{{Event("dragenter")}}{{DOMxRef("DragEvent")}}HTML5A dragged element or text selection enters a valid drop target.
{{Event("dragleave")}}{{DOMxRef("DragEvent")}}HTML5A dragged element or text selection leaves a valid drop target.
{{Event("dragover")}}{{DOMxRef("DragEvent")}}HTML5An element or text selection is being dragged over a valid drop target (every 350ms).
{{Event("dragstart")}}{{DOMxRef("DragEvent")}}HTML5The user starts dragging an element or text selection.
{{Event("drop")}}{{DOMxRef("DragEvent")}}HTML5An element is dropped on a valid drop target.
{{Event("durationchange")}}{{DOMxRef("Event")}}HTML5 mediaThe duration attribute has been updated.
{{Event("emptied")}}{{DOMxRef("Event")}}HTML5 mediaThe media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the load() method is called to reload it.
{{Event("end_(SpeechRecognition)","end")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}The speech recognition service has disconnected.
{{Event("end_(SpeechSynthesis)","end")}} {{Experimental_Inline}}{{DOMxRef("SpeechSynthesisEvent")}}{{SpecName("Web Speech API")}}The utterance has finished being spoken.
{{Event("ended")}}{{DOMxRef("Event")}}HTML5 mediaPlayback has stopped because the end of the media was reached.
{{Event("ended_(Web_Audio)", "ended")}}{{DOMxRef("Event")}}{{SpecName("Web Audio API")}}Playback has stopped because the end of the media was reached.
{{Event("endEvent")}}{{DOMxRef("TimeEvent")}}SVGA SMIL animation element ends.
{{Event("error")}}{{DOMxRef("UIEvent")}}DOM L3A resource failed to load.
{{Event("error")}}{{DOMxRef("ProgressEvent")}}Progress and XMLHttpRequestProgression has failed.
{{Event("error")}}{{DOMxRef("Event")}}WebSocketA WebSocket connection has been closed with prejudice (some data couldn't be sent for example).
{{Event("error")}}{{DOMxRef("Event")}}Server Sent EventsAn event source connection has been failed.
{{Event("error")}}{{DOMxRef("Event")}}IndexedDBA request caused an error and failed.
{{Event("error_(SpeechRecognitionError)","error")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}A speech recognition error occurs.
{{Event("error_(SpeechSynthesisError)","error")}}{{DOMxRef("SpeechSynthesisErrorEvent")}}{{SpecName('Web Speech API')}}An error occurs that prevents the utterance from being successfully spoken.
{{Event("focus")}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element has received focus (does not bubble).
{{Event("focusin")}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element is about to receive focus (bubbles).
{{Event("focusout")}}{{DOMxRef("FocusEvent")}} {{Experimental_Inline}}DOM L3An element is about to lose focus (bubbles).
{{Event("fullscreenchange")}}{{DOMxRef("Event")}}Full ScreenAn element was turned to fullscreen mode or back to normal mode.
{{Event("fullscreenerror")}}{{DOMxRef("Event")}}Full ScreenIt was impossible to switch to fullscreen mode for technical reasons or because the permission was denied.
{{Event("gamepadconnected")}}{{DOMxRef("GamepadEvent")}} {{Experimental_Inline}}GamepadA gamepad has been connected.
{{Event("gamepaddisconnected")}}{{DOMxRef("GamepadEvent")}} {{Experimental_Inline}}GamepadA gamepad has been disconnected.
{{Event("gotpointercapture")}}{{DOMxRef("PointerEvent")}}Pointer EventsElement receives pointer capture.
{{Event("hashchange")}}{{DOMxRef("HashChangeEvent")}}HTML5The fragment identifier of the URL has changed (the part of the URL after the #).
{{Event("lostpointercapture")}}{{DOMxRef("PointerEvent")}}Pointer EventsElement lost pointer capture.
{{Event("input")}}{{DOMxRef("Event")}}HTML5The value of an element changes or the content of an element with the attribute contenteditable is modified.
{{Event("invalid")}}{{DOMxRef("Event")}}HTML5A submittable element has been checked and doesn't satisfy its constraints.
{{Event("keydown")}}{{DOMxRef("KeyboardEvent")}}DOM L3A key is pressed down.
{{Event("keypress")}}{{DOMxRef("KeyboardEvent")}}DOM L3A key is pressed down and that key normally produces a character value (use input instead).
{{Event("keyup")}}{{DOMxRef("KeyboardEvent")}}DOM L3A key is released.
{{Event("languagechange")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{ SpecName('HTML5.1', '#dom-navigator-languages', 'NavigatorLanguage.languages') }}The user's preferred languages have changed.
{{Event("levelchange")}}{{DOMxRef("Event")}}Battery statusThe level attribute has been updated.
{{Event("load")}}{{DOMxRef("UIEvent")}}DOM L3A resource and its dependent resources have finished loading.
load{{DOMxRef("ProgressEvent")}}Progress and XMLHttpRequestProgression has been successful.
{{Event("loadeddata")}}{{DOMxRef("Event")}}HTML5 mediaThe first frame of the media has finished loading.
{{Event("loadedmetadata")}}{{DOMxRef("Event")}}HTML5 mediaThe metadata has been loaded.
{{Event("loadend")}}{{DOMxRef("ProgressEvent")}}Progress and XMLHttpRequestProgress has stopped (after "error", "abort" or "load" have been dispatched).
{{Event("loadstart")}}{{DOMxRef("ProgressEvent")}}Progress and XMLHttpRequestProgress has begun.
{{Event("mark")}} {{Experimental_Inline}}{{DOMxRef("SpeechSynthesisEvent")}}{{SpecName('Web Speech API')}}The spoken utterance reaches a named SSML "mark" tag.
message{{DOMxRef("MessageEvent")}}WebSocketA message is received through a WebSocket.
message{{DOMxRef("MessageEvent")}}Web WorkersA message is received from a Web Worker.
message{{DOMxRef("MessageEvent")}}Web MessagingA message is received from a child (i)frame or a parent window.
message{{DOMxRef("MessageEvent")}}Server Sent EventsA message is received through an event source.
{{Event("messageerror")}}{{DOMxRef("MessageEvent")}}{{DOMxRef("MessagePort")}}, Web Workers, Broadcast Channel, {{DOMxRef("Window")}}A message error is raised when a message is received by an object.
{{Event("message_(ServiceWorker)","message")}} {{Experimental_Inline}}{{DOMxRef("ServiceWorkerMessageEvent")}} or {{DOMxRef("ExtendableMessageEvent")}}, depending on context.Service WorkersA message is received from a service worker, or a message is received in a service worker from another context.
{{Event("mousedown")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device button (usually a mouse) is pressed on an element.
{{Event("mouseenter")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device is moved onto the element that has the listener attached.
{{Event("mouseleave")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device is moved off the element that has the listener attached.
{{Event("mousemove")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device is moved over an element.
{{Event("mouseout")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device is moved off the element that has the listener attached or off one of its children.
{{Event("mouseover")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device is moved onto the element that has the listener attached or onto one of its children.
{{Event("mouseup")}}{{DOMxRef("MouseEvent")}}DOM L3A pointing device button is released over an element.
{{Event("nomatch")}} {{Experimental_Inline}}{{DOMxRef("SpeechRecognitionEvent")}}{{SpecName('Web Speech API')}}The speech recognition service returns a final result with no significant recognition.
{{Event("notificationclick")}}{{DOMxRef("NotificationEvent")}} {{Experimental_Inline}}{{SpecName('Web Notifications','#dom-serviceworkerglobalscope-onnotificationclick','onnotificationclick')}}A system notification spawned by {{DOMxRef("ServiceWorkerRegistration.showNotification()")}} has been clicked.
{{Event("offline")}}{{DOMxRef("Event")}}HTML5 offlineThe browser has lost access to the network.
{{Event("online")}}{{DOMxRef("Event")}}HTML5 offlineThe browser has gained access to the network (but particular websites might be unreachable).
open{{DOMxRef("Event")}}WebSocketA WebSocket connection has been established.
open{{DOMxRef("Event")}}Server Sent EventsAn event source connection has been established.
{{Event("orientationchange")}}{{DOMxRef("Event")}}Screen OrientationThe orientation of the device (portrait/landscape) has changed
{{Event("pagehide")}}{{DOMxRef("PageTransitionEvent")}}HTML5A session history entry is being traversed from.
{{Event("pageshow")}}{{DOMxRef("PageTransitionEvent")}}HTML5A session history entry is being traversed to.
{{Event("paste")}}{{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}}ClipboardData has been transferred from the system clipboard to the document.
{{Event("pause")}}{{DOMxRef("Event")}}HTML5 mediaPlayback has been paused.
{{Event("pause_(SpeechSynthesis)", "pause")}} {{Experimental_Inline}}{{DOMxRef("SpeechSynthesisEvent")}}{{SpecName('Web Speech API')}}The utterance is paused part way through.
{{Event("pointercancel")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointer is unlikely to produce any more events.
{{Event("pointerdown")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointer enters the active buttons state.
{{Event("pointerenter")}}{{DOMxRef("PointerEvent")}}Pointer EventsPointing device is moved inside the hit-testing boundary.
{{Event("pointerleave")}}{{DOMxRef("PointerEvent")}}Pointer EventsPointing device is moved out of the hit-testing boundary.
{{Event("pointerlockchange")}}{{DOMxRef("Event")}}Pointer LockThe pointer was locked or released.
{{Event("pointerlockerror")}}{{DOMxRef("Event")}}Pointer LockIt was impossible to lock the pointer for technical reasons or because the permission was denied.
{{Event("pointermove")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointer changed coordinates.
{{Event("pointerout")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointing device moved out of hit-testing boundary or leaves detectable hover range.
{{Event("pointerover")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointing device is moved into the hit-testing boundary.
{{Event("pointerup")}}{{DOMxRef("PointerEvent")}}Pointer EventsThe pointer leaves the active buttons state.
{{Event("play")}}{{DOMxRef("Event")}}HTML5 mediaPlayback has begun.
{{Event("playing")}}{{DOMxRef("Event")}}HTML5 mediaPlayback is ready to start after having been paused or delayed due to lack of data.
{{Event("popstate")}}{{DOMxRef("PopStateEvent")}}HTML5A session history entry is being navigated to (in certain cases).
{{Event("progress")}}{{DOMxRef("ProgressEvent")}}Progress and XMLHttpRequestIn progress.
{{Event("push")}}{{DOMxRef("PushEvent")}} {{Experimental_Inline}}{{SpecName("Push API")}}A Service Worker has received a push message.
{{Event("pushsubscriptionchange")}}{{DOMxRef("PushEvent")}} {{Experimental_Inline}}{{SpecName("Push API")}}A PushSubscription has expired.
{{Event("ratechange")}}{{DOMxRef("Event")}}HTML5 mediaThe playback rate has changed.
{{Event("readystatechange")}}{{DOMxRef("Event")}}HTML5 and XMLHttpRequestThe readyState attribute of a document has changed.
{{Event("repeatEvent")}}{{DOMxRef("TimeEvent")}}SVGA SMIL animation element is repeated.
{{Event("reset")}}{{DOMxRef("Event")}}DOM L2, HTML5A form is reset.
{{Event("resize")}}{{DOMxRef("UIEvent")}}DOM L3The document view has been resized.
{{Event("resourcetimingbufferfull")}}{{DOMxRef("Performance")}}Resource TimingThe browser's resource timing buffer is full.
{{Event("result")}} {{Experimental_Inline}}{{DOMxRef("SpeechRecognitionEvent")}} {{Experimental_Inline}}{{SpecName('Web Speech API')}}The speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app.
{{Event("resume")}} {{Experimental_Inline}}{{DOMxRef("SpeechSynthesisEvent")}} {{Experimental_Inline}}{{SpecName('Web Speech API')}}A paused utterance is resumed.
{{Event("scroll")}}{{DOMxRef("UIEvent")}}DOM L3The document view or an element has been scrolled.
{{Event("seeked")}}{{DOMxRef("Event")}}HTML5 mediaA seek operation completed.
{{Event("seeking")}}{{DOMxRef("Event")}}HTML5 mediaA seek operation began.
{{Event("select")}}{{DOMxRef("UIEvent")}}DOM L3Some text is being selected.
{{Event("selectstart")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{ SpecName('Selection API')}}A selection just started.
{{Event("selectionchange")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{ SpecName('Selection API')}}The selection in the document has been changed.
{{Event("show")}}{{DOMxRef("MouseEvent")}}HTML5A contextmenu event was fired on/bubbled to an element that has a contextmenu attribute
{{Event("slotchange")}}{{DOMxRef("Event")}}{{ SpecName('DOM WHATWG')}}The node contents of a {{DOMxRef("HTMLSlotElement")}} ({{htmlelement("slot")}}) have changed.
{{Event("soundend")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}Any sound — recognisable speech or not — has stopped being detected.
{{Event("soundstart")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}Any sound — recognisable speech or not — has been detected.
{{Event("speechend")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}Speech recognised by the speech recognition service has stopped being detected.
{{Event("speechstart")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}Sound that is recognised by the speech recognition service as speech has been detected.
{{Event("stalled")}}{{DOMxRef("Event")}}HTML5 mediaThe user agent is trying to fetch media data, but data is unexpectedly not forthcoming.
{{Event("start_(SpeechRecognition)","start")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}The speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current SpeechRecognition.
{{Event("start_(SpeechSynthesis)","start")}}{{DOMxRef("SpeechSynthesisEvent")}}{{SpecName('Web Speech API')}}The utterance has begun to be spoken.
{{Event("storage")}}{{DOMxRef("StorageEvent")}}Web StorageA storage area (localStorage or sessionStorage) has changed.
{{Event("submit")}}{{DOMxRef("Event")}}DOM L2, HTML5A form is submitted.
success{{DOMxRef("Event")}}IndexedDBA request successfully completed.
{{Event("suspend")}}{{DOMxRef("Event")}}HTML5 mediaMedia data loading has been suspended.
{{Event("SVGAbort")}}{{DOMxRef("SVGEvent")}}SVGPage loading has been stopped before the SVG was loaded.
{{Event("SVGError")}}{{DOMxRef("SVGEvent")}}SVGAn error has occurred before the SVG was loaded.
{{Event("SVGLoad")}}{{DOMxRef("SVGEvent")}}SVGAn SVG document has been loaded and parsed.
{{Event("SVGResize")}}{{DOMxRef("SVGEvent")}}SVGAn SVG document is being resized.
{{Event("SVGScroll")}}{{DOMxRef("SVGEvent")}}SVGAn SVG document is being scrolled.
{{Event("SVGUnload")}}{{DOMxRef("SVGEvent")}}SVGAn SVG document has been removed from a window or frame.
{{Event("SVGZoom")}}{{DOMxRef("SVGZoomEvent")}}SVGAn SVG document is being zoomed.
{{Event("timeout")}}{{DOMxRef("ProgressEvent")}}XMLHttpRequest
{{Event("timeupdate")}}{{DOMxRef("Event")}}HTML5 mediaThe time indicated by the currentTime attribute has been updated.
{{Event("touchcancel")}}{{DOMxRef("TouchEvent")}}Touch EventsA touch point has been disrupted in an implementation-specific manners (too many touch points for example).
{{Event("touchend")}}{{DOMxRef("TouchEvent")}}Touch EventsA touch point is removed from the touch surface.
{{Event("touchmove")}}{{DOMxRef("TouchEvent")}}Touch EventsA touch point is moved along the touch surface.
{{Event("touchstart")}}{{DOMxRef("TouchEvent")}}Touch EventsA touch point is placed on the touch surface.
{{Event("transitionend")}}{{DOMxRef("TransitionEvent")}} {{Experimental_Inline}}CSS TransitionsA CSS transition has completed.
{{Event("unload")}}{{DOMxRef("UIEvent")}}DOM L3The document or a dependent resource is being unloaded.
upgradeneededIndexedDBAn attempt was made to open a database with a version number higher than its current version. A versionchange transaction has been created.
{{Event("userproximity")}}{{DOMxRef("UserProximityEvent")}} {{Experimental_Inline}}{{SpecName("Proximity Events")}}Fresh data is available from a proximity sensor (indicates whether the nearby object is near the device or not).
{{Event("voiceschanged")}} {{Experimental_Inline}}{{DOMxRef("Event")}}{{SpecName('Web Speech API')}}The list of {{DOMxRef("SpeechSynthesisVoice")}} objects that would be returned by the {{DOMxRef("SpeechSynthesis.getVoices()")}} method has changed (when the {{Event("voiceschanged")}} event fires.)
versionchangeIndexedDBA versionchange transaction completed.
{{Event("visibilitychange")}}{{DOMxRef("Event")}}Page visibilityThe content of a tab has become visible or has been hidden.
{{Event("volumechange")}}{{DOMxRef("Event")}}HTML5 mediaThe volume has changed.
{{Event("waiting")}}{{DOMxRef("Event")}}HTML5 mediaPlayback has stopped because of a temporary lack of data.
{{Event("wheel")}}{{DOMxRef("WheelEvent")}}DOM L3A wheel button of a pointing device is rotated in any direction.
- -

非标准事件

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event NameEvent TypeSpecificationFired when...
{{Event("afterscriptexecute")}}{{DOMxRef("Event")}}Mozilla SpecificA script has been executed.
{{Event("beforescriptexecute")}}{{DOMxRef("Event")}}Mozilla SpecificA script is about to be executed.
{{Event("beforeinstallprompt")}}{{DOMxRef("Event")}}Chrome specificA user is prompted to save a web site to a home screen on mobile.
{{Event("cardstatechange")}}Firefox OS specificThe {{DOMxRef("MozMobileConnection.cardState")}} property changes value.
{{Event("change")}}{{DOMxRef("DeviceStorageChangeEvent")}}Firefox OS specificThis event is triggered each time a file is created, modified or deleted on a given storage area.
{{Event("connectionInfoUpdate")}}Firefox OS specificThe informations about the signal strength and the link speed have been updated.
{{Event("cfstatechange")}}Firefox OS specificThe call forwarding state changes.
{{Event("datachange")}}Firefox OS specificThe {{DOMxRef("MozMobileConnection.data")}} object changes values.
{{Event("dataerror")}}Firefox OS specificThe {{DOMxRef("MozMobileConnection.data")}} object receive an error from the RIL.
{{Event("DOMMouseScroll")}}{{Deprecated_Inline}}Mozilla specificThe wheel button of a pointing device is rotated (detail attribute is a number of lines). (use {{Event("wheel")}} instead)
dragdrop {{Deprecated_Inline}}DragEventMozilla specificAn element is dropped (use {{Event("drop")}} instead).
dragexit {{Deprecated_Inline}}DragEventMozilla specificA drag operation is being ended(use {{Event("dragend")}} instead).
draggesture {{Deprecated_Inline}}DragEventMozilla specificThe user starts dragging an element or text selection (use {{Event("dragstart")}} instead).
{{Event("icccardlockerror")}}Firefox OS specificthe {{DOMxRef("MozMobileConnection.unlockCardLock()")}} or {{DOMxRef("MozMobileConnection.setCardLock()")}} methods fails.
{{Event("iccinfochange")}}Firefox OS specificThe {{DOMxRef("MozMobileConnection.iccInfo")}} object changes.
{{Event("localized")}}Mozilla SpecificThe page has been localized using data-l10n-* attributes.
{{Event("mousewheel")}} {{Deprecated_Inline}}IE inventedThe wheel button of a pointing device is rotated.
{{Event("MozAudioAvailable")}}{{DOMxRef("Event")}}Mozilla specificThe audio buffer is full and the corresponding raw samples are available.
MozBeforeResize {{Deprecated_Inline}}Mozilla specificA window is about to be resized.
{{Event("mozbrowseractivitydone")}}Firefox OS Browser API-specificSent when some activity has been completed (complete description TBD.)
{{Event("mozbrowserasyncscroll")}}Firefox OS Browser API-specificSent when the scroll position within a browser {{HTMLElement("iframe")}} changes.
{{Event("mozbrowseraudioplaybackchange")}}Firefox OS Browser API-specificSent when audio starts or stops playing within the browser {{HTMLElement("iframe")}} content.
{{Event("mozbrowsercaretstatechanged")}}Firefox OS Browser API-specificSent when the text selected inside the browser {{HTMLElement("iframe")}} content changes.
{{Event("mozbrowserclose")}}Firefox OS Browser API-specificSent when window.close() is called within a browser {{HTMLElement("iframe")}}.
{{Event("mozbrowsercontextmenu")}}Firefox OS Browser API-specificSent when a browser {{HTMLElement("iframe")}} try to open a context menu.
{{Event("mozbrowserdocumentfirstpaint")}}Firefox OS Browser API-specificSent when a new paint occurs on any document in the browser {{HTMLElement("iframe")}}.
{{Event("mozbrowsererror")}}Firefox OS Browser API-specificSent when an error occured while trying to load a content within a browser iframe
{{Event("mozbrowserfindchange")}}Firefox OS Browser API-specificSent when a search operation is performed on the browser {{HTMLElement("iframe")}} content (see HTMLIFrameElement search methods.)
{{Event("mozbrowserfirstpaint")}}Firefox OS Browser API-specificSent when the {{HTMLElement("iframe")}} paints content for the first time (this doesn't include the initial paint from about:blank.)
{{Event("mozbrowsericonchange")}}Firefox OS Browser API-specificSent when the favicon of a browser iframe changes.
{{Event("mozbrowserlocationchange")}}Firefox OS Browser API-specificSent when an browser iframe's location changes.
{{Event("mozbrowserloadend")}}Firefox OS Browser API-specificSent when the browser iframe has finished loading all its assets.
{{Event("mozbrowserloadstart")}}Firefox OS Browser API-specificSent when the browser iframe starts to load a new page.
{{Event("mozbrowsermanifestchange")}}Firefox OS Browser API-specificSent when a the path to the app manifest changes, in the case of a browser {{HTMLElement("iframe")}} with an open web app embedded in it.
{{Event("mozbrowsermetachange")}}Firefox OS Browser API-specificSent when a {{htmlelement("meta")}} elelment is added to, removed from or changed in the browser {{HTMLElement("iframe")}}'s content.
{{Event("mozbrowseropensearch")}}Firefox OS Browser API-specificSent when a link to a search engine is found.
{{Event("mozbrowseropentab")}}Firefox OS Browser API-specificSent when a new tab is opened within a browser {{HTMLElement("iframe")}} as a result of the user issuing a command to open a link target in a new tab (for example ctrl/cmd + click.)
{{Event("mozbrowseropenwindow")}}Firefox OS Browser API-specificSent when {{DOMxRef("window.open()")}} is called within a browser iframe.
{{Event("mozbrowserresize")}}Firefox OS Browser API-specificSent when the browser {{HTMLElement("iframe")}}'s window size has changed.
{{Event("mozbrowserscroll")}}Firefox OS Browser API-specificSent when the browser {{HTMLElement("iframe")}} content scrolls.
{{Event("mozbrowserscrollareachanged")}}Firefox OS Browser API-specificSent when the available scrolling area in the browser {{HTMLElement("iframe")}} changes. This can occur on resize and when the page size changes (while loading for example.)
{{Event("mozbrowserscrollviewchange")}}Firefox OS Browser API-specificSent when asynchronous scrolling (i.e. APCZ) starts or stops.
{{Event("mozbrowsersecuritychange")}}Firefox OS Browser API-specificSent when the SSL state changes within a browser iframe.
{{Event("mozbrowserselectionstatechanged")}}Firefox OS Browser API-specificSent when the text selected inside the browser {{HTMLElement("iframe")}} content changes. Note that this is deprecated, and newer implementations use {{Event("mozbrowsercaretstatechanged")}} instead.
{{Event("mozbrowsershowmodalprompt")}}Firefox OS Browser API-specificSent when {{DOMxRef("window.alert","alert()")}}, {{DOMxRef("window.confirm","confirm()")}} or {{DOMxRef("window.prompt","prompt()")}} are called within a browser iframe
{{Event("mozbrowsertitlechange")}}Firefox OS Browser API-specificSent when the document.title changes within a browser iframe.
{{Event("mozbrowserusernameandpasswordrequired")}}Firefox OS Browser API-specificSent when an HTTP authentification is requested.
{{Event("mozbrowservisibilitychange")}}Firefox OS Browser API-specificSent when the visibility state of the current browser iframe {{HTMLElement("iframe")}} changes, for example due to a call to {{DOMxRef("HTMLIFrameElement.setVisible","setVisible()")}}.
{{Event("MozGamepadButtonDown")}}To be specifiedA gamepad button is pressed down.
{{Event("MozGamepadButtonUp")}}To be specifiedA gamepad button is released.
{{Event("MozMousePixelScroll")}} {{Deprecated_Inline}}Mozilla specificThe wheel button of a pointing device is rotated (detail attribute is a number of pixels). (use wheel instead)
{{Event("MozOrientation")}} {{Deprecated_Inline}}Mozilla specificFresh data is available from an orientation sensor (see deviceorientation).
{{Event("MozScrolledAreaChanged")}}{{DOMxRef("UIEvent")}}Mozilla specificThe document view has been scrolled or resized.
{{Event("moztimechange")}}Mozilla specificThe time of the device has been changed.
MozTouchDown {{Deprecated_Inline}}Mozilla specificA touch point is placed on the touch surface (use touchstart instead).
MozTouchMove {{Deprecated_Inline}}Mozilla specificA touch point is moved along the touch surface (use touchmove instead).
MozTouchUp {{Deprecated_Inline}}Mozilla specificA touch point is removed from the touch surface (use touchend instead).
{{Event("alerting")}}{{DOMxRef("CallEvent")}}To be specifiedThe correspondent is being alerted (his/her phone is ringing).
{{Event("busy")}}{{DOMxRef("CallEvent")}}To be specifiedThe line of the correspondent is busy.
{{Event("callschanged")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been added or removed from the list of current calls.
onconnected {{Event("connected")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been connected.
{{Event("connecting")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to connect.
{{Event("delivered")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been successfully delivered.
{{Event("dialing")}}{{DOMxRef("CallEvent")}}To be specifiedThe number of a correspondent has been dialed.
{{Event("disabled")}}Firefox OS specificWifi has been disabled on the device.
{{Event("disconnected")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been disconnected.
{{Event("disconnecting")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to disconnect.
{{Event("enabled")}}Firefox OS specificWifi has been enabled on the device.
{{Event("error_(Telephony)","error")}}{{DOMxRef("CallEvent")}}To be specifiedAn error occurred.
{{Event("held")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been held.
{{Event("holding")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to be held.
{{Event("incoming")}}{{DOMxRef("CallEvent")}}To be specifiedA call is being received.
{{Event("received")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been received.
{{Event("resuming")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to resume.
{{Event("sent")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been sent.
{{Event("statechange")}}{{DOMxRef("CallEvent")}}To be specifiedThe state of a call has changed.
{{Event("statuschange")}}Firefox OS specificThe status of the Wifi connection changed.
{{Event("overflow")}}{{DOMxRef("UIEvent")}}Mozilla specificAn element has been overflowed by its content or has been rendered for the first time in this state (only works for elements styled with overflow != visible).
{{Event("smartcard-insert")}}Mozilla specificA smartcard has been inserted.
{{Event("smartcard-remove")}}Mozilla specificA smartcard has been removed.
{{Event("stkcommand")}}Firefox OS specificThe STK Proactive Command is issued from ICC.
{{Event("stksessionend")}}Firefox OS specificThe STK Session is terminated by ICC.
{{Event("touchenter")}}{{DOMxRef("TouchEvent")}}Touch Events Removed
{{Event("touchleave")}}{{DOMxRef("TouchEvent")}}Touch Events Removed
{{Event("underflow")}}{{DOMxRef("UIEvent")}}Mozilla specificAn element is no longer overflowed by its content (only works for elements styled with overflow != visible).
uploadprogress {{Deprecated_Inline}}{{DOMxRef("ProgressEvent")}}Mozilla SpecificUpload is in progress (see {{Event("progress")}}).
-

{{Event("ussdreceived")}}

-
Firefox OS specificA new USSD message is received
{{Event("voicechange")}}Firefox OS specificThe {{DOMxRef("MozMobileConnection.voice")}} object changes values.
{{Event("msContentZoom")}}Microsoft specific
{{Event("MSManipulationStateChanged")}}Microsoft specific
{{Event("MSPointerHover")}} {{Deprecated_Inline}}Microsoft specific
- -

Mozilla 特定事件

- -
-

备注: 这些事件不会暴露给 Web 内容使用,只能在 chrome 内容的上下文中使用。

-
- -

XUL 事件

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event NameEvent TypeSpecificationFired when...
{{Event("broadcast")}}XULAn observer noticed a change to the attributes of a watched broadcaster.
{{Event("CheckboxStateChange")}}XULThe state of a checkbox has been changed either by a user action or by a script (useful for accessibility).
closeXULThe close button of the window has been clicked.
{{Event("command")}}XULAn element has been activated.
{{Event("commandupdate")}}XULA command update occurred on a commandset element.
{{Event("DOMMenuItemActive")}}XULA menu or menuitem has been hovered or highlighted.
{{Event("DOMMenuItemInactive")}}XULA menu or menuitem is no longer hovered or highlighted.
{{Event("popuphidden")}}PopupEventXULA menupopup, panel or tooltip has been hidden.
{{Event("popuphiding")}}PopupEventXULA menupopup, panel or tooltip is about to be hidden.
{{Event("popupshowing")}}PopupEventXULA menupopup, panel or tooltip is about to become visible.
{{Event("popupshown")}}PopupEventXULA menupopup, panel or tooltip has become visible.
{{Event("RadioStateChange")}}XULThe state of a radio has been changed either by a user action or by a script (useful for accessibility).
{{Event("ValueChange")}}XULThe value of an element has changed (a progress bar for example, useful for accessibility).
- -

附加组件特定事件

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event NameEvent TypeSpecificationFired when...
MozSwipeGestureAddons specificA touch point is swiped across the touch surface
MozMagnifyGestureStartAddons specificTwo touch points start to move away from each other.
MozMagnifyGestureUpdateAddons specificTwo touch points move away from each other (after a MozMagnifyGestureStart).
MozMagnifyGestureAddons specificTwo touch points moved away from each other (after a sequence of MozMagnifyGestureUpdate).
MozRotateGestureStartAddons specificTwo touch points start to rotate around a point.
MozRotateGestureUpdateAddons specificTwo touch points rotate around a point (after a MozRotateGestureStart).
MozRotateGestureAddons specificTwo touch points rotate around a point (after a sequence of MozRotateGestureUpdate).
MozTapGestureAddons specificTwo touch points are tapped on the touch surface.
MozPressTapGestureAddons specificA "press-tap" gesture happened on the touch surface (first finger down, second finger down, second finger up, first finger up).
MozEdgeUIGestureAddons specificA touch point is swiped across the touch surface to invoke the edge UI (Win8 only).
MozAfterPaintAddons specificContent has been repainted.
DOMPopupBlockedAddons specificA popup has been blocked
DOMWindowCreatedAddons specificA window has been created.
DOMWindowCloseAddons specificA window is about to be closed.
DOMTitleChangedAddons specifcThe title of a window has changed.
DOMLinkAddedAddons specifcA link has been added a document.
DOMLinkRemovedAddons specifcA link has been removed inside from a document.
DOMMetaAddedAddons specificA meta element has been added to a document.
DOMMetaRemovedAddons specificA meta element has been removed from a document.
DOMWillOpenModalDialogAddons specificA modal dialog is about to open.
DOMModalDialogClosedAddons specificA modal dialog has been closed.
DOMAutoCompleteAddons specificThe content of an element has been auto-completed.
DOMFrameContentLoadedAddons specificThe frame has finished loading (but not its dependent resources).
AlertActiveAddons specificA notification element is shown.
AlertCloseAddons specificA notification element is closed.
fullscreenAddons specificBrowser fullscreen mode has been entered or left.
sizemodechangeAddons specificWindow has entered/left fullscreen mode, or has been minimized/unminimized.
MozEnteredDomFullscreenAddons specificDOM fullscreen mode has been entered.
SSWindowClosingAddons specificThe session store will stop tracking this window.
SSTabClosingAddons specificThe session store will stop tracking this tab.
SSTabRestoringAddons specificA tab is about to be restored.
SSTabRestoredAddons specificA tab has been restored.
SSWindowStateReadyAddons specificA window state has switched to "ready".
SSWindowStateBusyAddons specificA window state has switched to "busy".
TabOpenAddons specificA tab has been opened.
TabCloseAddons specificA tab has been closed.
TabSelectAddons specificA tab has been selected.
TabShowAddons specificA tab has been shown.
TabHideAddons specificA tab has been hidden.
TabPinnedAddons specificA tab has been pinned.
TabUnpinnedAddons specificA tab has been unpinned.
- -

开发者工具特定事件

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Event NameEvent TypeSpecificationFired when...
CssRuleViewRefresheddevtools specificThe "Rules" view of the style inspector has been updated.
CssRuleViewChangeddevtools specificThe "Rules" view of the style inspector has been changed.
CssRuleViewCSSLinkClickeddevtools specificA link to a CSS file has been clicked in the "Rules" view of the style inspector.
- -

规范

- -{{Specifications}} - -

参见

- - diff --git a/files/zh-cn/web/events/index.md b/files/zh-cn/web/events/index.md new file mode 100644 index 00000000000000..c696ea2d9e44c1 --- /dev/null +++ b/files/zh-cn/web/events/index.md @@ -0,0 +1,1559 @@ +--- +title: 事件参考 +slug: Web/Events +tags: + - Event + - Web + - 事件 + - 参考 + - 总览 +translation_of: Web/Events +--- +发送 DOM 事件是为了将发生的相关事情通知代码。每个事件都是继承自{{DOMxRef("Event")}} 接口的对象,可以包括自定义的成员属性及函数用于获取事件发生时相关的更多信息。事件可以表示任何从基本的用户交互、到发生在渲染模型自动通知的任何事情。 + +本文提供了一个可以发送的事件的列表;一些是官方标准中的标准事件,另一些则是在特定浏览器内部使用的事件;例如,列出的 Mozilla 特定事件,使[附加组件](/zh-CN/docs/Mozilla/Add-ons)可以借助它们与浏览器进行交互。 + +## 最常见的类别 + +| 事件名称 | 何时触发 | +| -------------------------------- | ------------------------------------- | +| {{Event("error")}} | 资源加载失败时。 | +| {{Event("abort")}} | 正在加载资源已经被中止时。 | +| {{Event("load")}} | 资源及其相关资源已完成加载。 | +| {{Event("beforeunload")}} | window,document 及其资源即将被卸载。 | +| {{Event("unload")}} | 文档或一个依赖资源正在被卸载。 | + +### 网络事件 + +| 事件名称 | 何时触发 | +| ---------------------------- | ---------------------- | +| {{Event("online")}} | 浏览器已获得网络访问。 | +| {{Event("offline")}} | 浏览器已失去网络访问。 | + +### 焦点事件 + +| 事件名称 | 何时触发 | +| ------------------------ | -------------------------- | +| {{Event("focus")}} | 元素获得焦点(不会冒泡)。 | +| {{Event("blur")}} | 元素失去焦点(不会冒泡)。 | + +### WebSocket 事件 + +| 事件名称 | 何时触发 | +| --------------------------------------------------------------- | -------------------------------------------------- | +| [`open`](/zh-CN/docs/Web/Reference/Events/open_websocket) | WebSocket 连接已建立。 | +| [`message`](/zh-CN/docs/Web/Reference/Events/message_websocket) | 通过 WebSocket 接收到一条消息。 | +| {{Event("error")}} | WebSocket 连接异常被关闭(比如有些数据无法发送)。 | +| [`close`](/zh-CN/docs/Web/Reference/Events/close_websocket) | WebSocket 连接已关闭。 | + +### 会话历史事件 + +| 事件名称 | 何时触发 | +| ---------------------------- | ----------------------------------------------------------------- | +| {{Event("pagehide")}} | A session history entry is being traversed from. | +| {{Event("pageshow")}} | A session history entry is being traversed to. | +| {{Event("popstate")}} | A session history entry is being navigated to (in certain cases). | + +### CSS 动画事件 + +| 事件名称 | 何时触发 | +| ---------------------------------------- | ----------------------------------- | +| {{Event("animationstart")}} | 某个 CSS 动画开始时触发。 | +| {{Event("animationend")}} | 某个 CSS 动画完成时触发。 | +| {{Event("animationiteration")}} | 某个 CSS 动画完成后重新开始时触发。 | + +### CSS 过渡事件 + +| 事件名称 | 何时触发 | +| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| {{Event("transitionstart")}} | A [CSS transition](/zh-CN/docs/Web/CSS/CSS_Transitions) has actually started (fired after any delay). | +| {{Event("transitioncancel")}} | CSS 过渡被取消 | +| {{Event("transitionend")}} | CSS 过渡已经完成 | +| {{Event("transitionrun")}} | A [CSS transition](/zh-CN/docs/Web/CSS/CSS_Transitions) has begun running (fired before any delay starts). | + +### 表单事件 + +| 事件名称 | 何时触发 | +| ------------------------ | -------------- | +| {{Event("reset")}} | 点击重置按钮时 | +| {{Event("submit")}} | 点击提交按钮 | + +### 打印事件 + +| 事件名称 | 何时触发 | +| -------------------------------- | -------------------- | +| {{Event("beforeprint")}} | 打印机已经就绪时触发 | +| {{Event("afterprint")}} | 打印机关闭时触发 | + +### 文本写作事件 + +| Event Name | Fired When | +| ---------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| {{Event("compositionstart")}} | The composition of a passage of text is prepared (similar to keydown for a keyboard input, but works with other inputs such as speech recognition). | +| {{Event("compositionupdate")}} | A character is added to a passage of text being composed. | +| {{Event("compositionend")}} | The composition of a passage of text has been completed or canceled. | + +### 视图事件 + +| Event Name | Fired When | +| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- | +| {{Event("fullscreenchange")}} | An element was turned to fullscreen mode or back to normal mode. | +| {{Event("fullscreenerror")}} | It was impossible to switch to fullscreen mode for technical reasons or because the permission was denied. | +| {{Event("resize")}} | The document view has been resized. | +| {{Event("scroll")}} | The document view or an element has been scrolled. | + +### 剪贴板事件 + +| Event Name | Fired When | +| ------------------------ | ------------------------------------------ | +| {{Event("cut")}} | 已经剪贴选中的文本内容并且复制到了剪贴板。 | +| {{Event("copy")}} | 已经把选中的文本内容复制到了剪贴板。 | +| {{Event("paste")}} | 从剪贴板复制的文本内容被粘贴。 | + +### 键盘事件 + +| Event Name | Fired When | +| ---------------------------- | ------------------------------------------------------- | +| {{Event("keydown")}} | 按下任意按键。 | +| {{Event("keypress")}} | 除 Shift、Fn、CapsLock 外的任意键被按住。(连续触发。) | +| {{Event("keyup")}} | 释放任意按键。 | + +### 鼠标事件 + +| Event Name | Fired When | +| ---------------------------------------- | ---------------------------------------------------------------------------------------------- | +| {{Event("auxclick")}} | A pointing device button (ANY non-primary button) has been pressed and released on an element. | +| {{Event("click")}} | 在元素上按下并释放任意鼠标按键。 | +| {{Event("contextmenu")}} | 右键点击(在右键菜单显示前触发)。 | +| {{Event("dblclick")}} | 在元素上双击鼠标按钮。 | +| {{Event("mousedown")}} | 在元素上按下任意鼠标按钮。 | +| {{Event("mouseenter")}} | 指针移到有事件监听的元素内。 | +| {{Event("mouseleave")}} | 指针移出元素范围外(不冒泡)。 | +| {{Event("mousemove")}} | 指针在元素内移动时持续触发。 | +| {{Event("mouseover")}} | 指针移到有事件监听的元素或者它的子元素内。 | +| {{Event("mouseout")}} | 指针移出元素,或者移到它的子元素上。 | +| {{Event("mouseup")}} | 在元素上释放任意鼠标按键。 | +| {{Event("pointerlockchange")}} | 鼠标被锁定或者解除锁定发生时。 | +| {{Event("pointerlockerror")}} | 可能因为一些技术的原因鼠标锁定被禁止时。 | +| {{Event("select")}} | 有文本被选中。 | +| {{Event("wheel")}} | 滚轮向任意方向滚动。 | + +### 拖放事件 + +| Event Name | Fired When | +| ---------------------------- | --------------------------------------------------------------------------------------- | +| {{Event("drag")}} | 正在拖动元素或文本选区(在此过程中持续触发,每 350ms 触发一次) | +| {{Event("dragend")}} | 拖放操作结束。(松开鼠标按钮或按下 Esc 键) | +| {{Event("dragenter")}} | 被拖动的元素或文本选区移入有效释放目标区 | +| {{Event("dragstart")}} | 用户开始拖动 HTML 元素或选中的文本 | +| {{Event("dragleave")}} | 被拖动的元素或文本选区移出有效释放目标区 | +| {{Event("dragover")}} | 被拖动的元素或文本选区正在有效释放目标上被拖动(在此过程中持续触发,每 350ms 触发一次) | +| {{Event("drop")}} | 元素在有效释放目标区上释放 | + +### 媒体事件 + +| Event Name | Fired When | +| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| {{Event("audioprocess")}} | The input buffer of a {{DOMxRef("ScriptProcessorNode")}} is ready to be processed. | +| {{Event("canplay")}} | The browser can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content. | +| {{Event("canplaythrough")}} | The browser estimates it can play the media up to its end without stopping for content buffering. | +| {{Event("complete")}} | The rendering of an {{DOMxRef("OfflineAudioContext")}} is terminated. | +| {{Event("durationchange")}} | The `duration` attribute has been updated. | +| {{Event("emptied")}} | The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the [`load()`](/zh-CN/docs/XPCOM_Interface_Reference/NsIDOMHTMLMediaElement) method is called to reload it. | +| {{Event("ended")}} | Playback has stopped because the end of the media was reached. | +| {{Event("loadeddata")}} | The first frame of the media has finished loading. | +| {{Event("loadedmetadata")}} | The metadata has been loaded. | +| {{Event("pause")}} | Playback has been paused. | +| {{Event("play")}} | Playback has begun. | +| {{Event("playing")}} | Playback is ready to start after having been paused or delayed due to lack of data. | +| {{Event("ratechange")}} | The playback rate has changed. | +| {{Event("seeked")}} | A _seek_ operation completed. | +| {{Event("seeking")}} | A _seek_ operation began. | +| {{Event("stalled")}} | The user agent is trying to fetch media data, but data is unexpectedly not forthcoming. | +| {{Event("suspend")}} | Media data loading has been suspended. | +| {{Event("timeupdate")}} | The time indicated by the `currentTime` attribute has been updated. | +| {{Event("volumechange")}} | The volume has changed. | +| {{Event("waiting")}} | Playback has stopped because of a temporary lack of data. | + +### 进度事件 + +| Event Name | Fired When | +| --------------------------------------------------------- | ----------------------------------------------------------------------------- | +| [`abort`](/zh-CN/docs/Web/API/XMLHttpRequest/abort_event) | Progression has been terminated (not due to an error). | +| {{Event("error")}} | Progression has failed. | +| [`load`](/zh-CN/docs/Web/API/XMLHttpRequest/load_event) | Progression has been successful. | +| {{Event("loadend")}} | Progress has stopped (after "error", "abort" or "load" have been dispatched). | +| {{Event("loadstart")}} | Progress has begun. | +| {{Event("progress")}} | In progress. | +| {{Event("timeout")}} | Progression is terminated due to preset time expiring. | + +### 存储事件 + +{{Event("change")}} (参见 [非标准事件](#非标准事件)) +{{Event("storage")}} + +### 更新事件 + +{{Event("checking")}} +{{Event("downloading")}} +{{Event("error")}} +{{Event("noupdate")}} +{{Event("obsolete")}} +{{Event("updateready")}} + +### 值变化事件 + +{{Event("broadcast")}} +{{Event("CheckboxStateChange")}} +{{Event("hashchange")}} +{{Event("input")}} +{{Event("RadioStateChange")}} +{{Event("readystatechange")}} +{{Event("ValueChange")}} + +### 未分类的事件 + +{{Event("invalid")}} +[`message`](/zh-CN/docs/Web/API/DedicatedWorkerGlobalScope/message_event) +[`message`](/zh-CN/docs/Web/API/EventSource/message_event) +[`open`](/zh-CN/docs/Web/API/EventSource/open_event) +[`show`](/zh-CN/docs/Web/API/Element/show_event) + +## 不常见和非标准事件 + +### Abortable Fetch events + +| Event name | Fired when | +| ------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| [`abort`](/zh-CN/docs/Web/API/AbortSignal/abort_event) | A DOM request is aborted, i.e. using {{DOMxRef("AbortController.abort()")}}. | + +### WebVR events + +| Event name | Fired when | +| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| {{Event("vrdisplayactivate")}} | When a VR display is able to be presented to, for example if an HMD has been moved to bring it out of standby, or woken up by being put on. | +| {{Event("vrdisplayblur")}} | when presentation to a {{DOMxRef("VRDisplay")}} has been paused for some reason by the browser, OS, or VR hardware — for example, while the user is interacting with a system menu or browser, to prevent tracking or loss of experience. | +| {{Event("vrdisplayconnect")}} | when a compatible {{DOMxRef("VRDisplay")}} is connected to the computer. | +| {{Event("vrdisplaydeactivate")}} | When a {{DOMxRef("VRDisplay")}} can no longer be presented to, for example if an HMD has gone into standby or sleep mode due to a period of inactivity. | +| {{Event("vrdisplaydisconnect")}} | When a compatible {{DOMxRef("VRDisplay")}} is disconnected from the computer. | +| {{Event("vrdisplayfocus")}} | When presentation to a {{DOMxRef("VRDisplay")}} has resumed after being blurred. | +| {{Event("vrdisplaypresentchange")}} | The presenting state of a {{DOMxRef("VRDisplay")}} changes — i.e. goes from presenting to not presenting, or vice versa. | + +### SVG 事件 + +{{Event("SVGAbort")}} +{{Event("SVGError")}} +{{Event("SVGLoad")}} +{{Event("SVGResize")}} +{{Event("SVGScroll")}} +{{Event("SVGUnload")}} +{{Event("SVGZoom")}} + +### 数据库事件 + +[`abort`](/zh-CN/docs/Web/Reference/Events/abort_indexedDB) +[`blocked`](/zh-CN/docs/Web/Reference/Events/blocked_indexedDB) +[`complete`](/zh-CN/docs/Web/Reference/Events/complete_indexedDB) +{{Event("error")}} +[`success`](/zh-CN/docs/Web/Reference/Events/success_indexedDB) +[`upgradeneeded`](/zh-CN/docs/Web/Reference/Events/upgradeneeded_indexedDB) +[`versionchange`](/zh-CN/docs/Web/Reference/Events/versionchange_indexedDB) + +### 脚本事件 + +{{Event("afterscriptexecute")}} +{{Event("beforescriptexecute")}} + +### 菜单事件 + +{{Event("DOMMenuItemActive")}} +{{Event("DOMMenuItemInactive")}} + +### 窗口事件 + +[`close`](/zh-CN/docs/Mozilla/Tech/XUL/Events/close_event) + +### 弹出事件 + +{{Event("popuphidden")}} +{{Event("popuphiding")}} +{{Event("popupshowing")}} +{{Event("popupshown")}} + +### Tab 事件 + +{{Event("visibilitychange")}} + +### 电池事件 + +{{Event("chargingchange")}} +{{Event("chargingtimechange")}} +{{Event("dischargingtimechange")}} +{{Event("levelchange")}} + +### 呼叫事件 + +{{Event("alerting")}} +{{Event("busy")}} +{{Event("callschanged")}} +{{Event("cfstatechange")}} +{{Event("connected")}} +{{Event("connecting")}} +{{Event("dialing")}} +{{Event("disconnected")}} +{{Event("disconnecting")}} +{{Event("error_(Telephony)","error")}} +{{Event("held")}}, {{Event("holding")}} +{{Event("incoming")}} +{{Event("resuming")}} +{{Event("statechange")}} +{{Event("voicechange")}} + +### 传感器事件 + +{{Event("compassneedscalibration")}} +{{Event("devicemotion")}} +{{Event("deviceorientation")}} +{{Event("orientationchange")}} + +### 智能卡事件 + +{{Event("icccardlockerror")}} +{{Event("iccinfochange")}} +{{Event("smartcard-insert")}} +{{Event("smartcard-remove")}} +{{Event("stkcommand")}} +{{Event("stksessionend")}} +{{Event("cardstatechange")}} + +### 短信和 USSD 事件 + +{{Event("delivered")}} +{{Event("received")}} +{{Event("sent")}} +{{Event("ussdreceived")}} + +### 帧事件 + +{{Event("mozbrowserclose")}} +{{Event("mozbrowsercontextmenu")}} +{{Event("mozbrowsererror")}} +{{Event("mozbrowsericonchange")}} +{{Event("mozbrowserlocationchange")}} +{{Event("mozbrowserloadend")}} +{{Event("mozbrowserloadstart")}} +{{Event("mozbrowseropenwindow")}} +{{Event("mozbrowsersecuritychange")}} +{{Event("mozbrowsershowmodalprompt")}} +{{Event("mozbrowsertitlechange")}} + +### DOM 变异事件 + +[`DOMAttributeNameChanged`](/zh-CN/docs/DOM/Mutation_events) +[`DOMAttrModified`](/zh-CN/docs/DOM/Mutation_events) +[`DOMCharacterDataModified`](/zh-CN/docs/DOM/Mutation_events) +{{Event("DOMContentLoaded")}} +[`DOMElementNameChanged`](/zh-CN/docs/DOM/Mutation_events) +[`DOMNodeInserted`](/zh-CN/docs/DOM/Mutation_events) +[`DOMNodeInsertedIntoDocument`](/zh-CN/docs/DOM/Mutation_events) +[`DOMNodeRemoved`](/zh-CN/docs/DOM/Mutation_events) +[`DOMNodeRemovedFromDocument`](/zh-CN/docs/DOM/Mutation_events) +[`DOMSubtreeModified`](/zh-CN/docs/DOM/Mutation_events) + +### 触摸事件 + +{{Event("touchcancel")}} +{{Event("touchend")}} +{{Event("touchmove")}} +{{Event("touchstart")}} + +### 指针事件 + +{{Event("pointerover")}} +{{Event("pointerenter")}} +{{Event("pointerdown")}} +{{Event("pointermove")}} +{{Event("pointerup")}} +{{Event("pointercancel")}} +{{Event("pointerout")}} +{{Event("pointerleave")}} +{{Event("gotpointercapture")}} +{{Event("lostpointercapture")}} + +## 标准事件 + +这些事件在官方 Web 规范中定义,并且应在各个浏览器中通用。 每个事件都和代表事件接收方的对象(由此您可以查到每个事件提供的数据),定义这个事件的标准或标准链接会一起列出。 + +| 事件名称 | 事件类型 | 规范 | 触发时机... | +| ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| {{Event("abort")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-abort) | 资源载入已被中止 | +| [`abort`]() | {{DOMxRef("ProgressEvent")}} | [Progress](http://www.w3.org/TR/progress-events/)and[XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-abort) | Progress 被终止 (不是 error 造成的) | +| [`abort`](/zh-CN/docs/Web/Reference/Events/abort_indexedDB) | {{DOMxRef("Event")}} | [IndexedDB](http://www.w3.org/TR/IndexedDB/#database-interface) | 事务已被中止 | +| {{Event("afterprint")}} | {{DOMxRef("Event")}} | [HTML5](http://www.w3.org/TR/html5/webappapis.html#printing) | 相关文档已开始打印或打印预览已被关闭 | +| {{Event("animationcancel")}} | {{DOMxRef("AnimationEvent")}} {{Experimental_Inline}} | [CSS Animations](http://www.w3.org/TR/css3-animations/#animation-events) | A [CSS animation](/zh-CN/docs/CSS/CSS_animations) has aborted. | +| {{Event("animationend")}} | {{DOMxRef("AnimationEvent")}} {{Experimental_Inline}} | [CSS Animations](http://www.w3.org/TR/css3-animations/#animation-events) | 完成一个[CSS 动画](/zh-CN/docs/CSS/CSS_animations) | +| {{Event("animationiteration")}} | {{DOMxRef("AnimationEvent")}} {{Experimental_Inline}} | [CSS Animations](http://www.w3.org/TR/css3-animations/#animation-events) | 重复播放一个[CSS 动画](/zh-CN/docs/CSS/CSS_animations) | +| {{Event("animationstart")}} | {{DOMxRef("AnimationEvent")}} {{Experimental_Inline}} | [CSS Animations](http://www.w3.org/TR/css3-animations/#animation-events) | 一个 [CSS 动画](/zh-CN/docs/CSS/CSS_animations)已开始 | +| {{Event("appinstalled")}} | {{DOMxRef("Event")}} | [Web App Manifest](/zh-CN/docs/Web/Manifest) | A web application is successfully installed as a [progressive web app](/en-US/Apps/Progressive). | +| {{Event("audioprocess")}} | {{DOMxRef("AudioProcessingEvent")}} {{Deprecated_Inline}} | {{SpecName('Web Audio API', '#AudioProcessingEvent', 'audioprocess')}} | 一个{{DOMxRef("ScriptProcessorNode")}} 的输入缓冲区可处理 | +| {{Event("audioend")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | 用户代理捕捉到用以语音识别的音频 | +| {{Event("audiostart")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | 用户代理开始捕捉用以语音识别的音频 | +| {{Event("beforeprint")}} | {{DOMxRef("Event")}} | [HTML5](http://www.w3.org/TR/html5/webappapis.html#printing) | 相关文档将要开始打印或准备打印预览 | +| {{Event("beforeunload")}} | {{DOMxRef("BeforeUnloadEvent")}} | [HTML5](http://www.w3.org/TR/html5/browsers.html#unloading-documents) | 即将卸载 window,document 及其资源 | +| {{Event("beginEvent")}} | {{DOMxRef("TimeEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | A [SMIL](/zh-CN/docs/SVG/SVG_animation_with_SMIL) animation element begins. | +| [`blocked`](/zh-CN/docs/Web/Reference/Events/blocked_indexedDB) | | [IndexedDB](http://www.w3.org/TR/IndexedDB/#request-api) | An open connection to a database is blocking a `versionchange` transaction on the same database. | +| {{Event("blur")}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-blur) | An element has lost focus (does not bubble). | +| {{Event("boundary")}} {{Experimental_Inline}} | {{DOMxRef("SpeechSynthesisEvent")}} | {{SpecName('Web Speech API')}} | The spoken utterance reaches a word or sentence boundary | +| {{Event("canplay")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-canplay) | The user agent can play the media, but estimates that not enough data has been loaded to play the media up to its end without having to stop for further buffering of content. | +| {{Event("canplaythrough")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-canplaythrough) | The user agent can play the media up to its end without having to stop for further buffering of content. | +| {{Event("change")}} | {{DOMxRef("Event")}} | [DOM L2](http://www.w3.org/TR/DOM-Level-2-Events/events.html), [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#event-input-change) | The `change` event is fired for {{HTMLElement("input")}}, {{HTMLElement("select")}}, and {{HTMLElement("textarea")}} elements when a change to the element's value is committed by the user. | +| {{Event("chargingchange")}} | {{DOMxRef("Event")}} | [Battery status](https://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html) | The battery begins or stops charging. | +| {{Event("chargingtimechange")}} | {{DOMxRef("Event")}} | [Battery status](https://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html) | The `chargingTime` attribute has been updated. | +| {{Event("click")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-click) | A pointing device button has been pressed and released on an element. | +| [`close`](/zh-CN/docs/Web/Reference/Events/close_websocket) | {{DOMxRef("Event")}} | [WebSocket](http://www.w3.org/TR/websockets/) | A WebSocket connection has been closed. | +| [`complete`](/zh-CN/docs/Web/Reference/Events/complete_indexedDB) | | [IndexedDB](http://www.w3.org/TR/IndexedDB/#transaction) | A transaction successfully completed. | +| {{Event("complete")}} | {{DOMxRef("OfflineAudioCompletionEvent")}} {{Deprecated_Inline}} | {{SpecName('Web Audio API', '#OfflineAudioCompletionEvent-section', 'OfflineAudioCompletionEvent')}} | The rendering of an {{DOMxRef("OfflineAudioContext")}} is terminated. | +| {{Event("compositionend")}} | {{DOMxRef("CompositionEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-compositionend) | The composition of a passage of text has been completed or canceled. | +| {{Event("compositionstart")}} | {{DOMxRef("CompositionEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-compositionstart) | The composition of a passage of text is prepared (similar to keydown for a keyboard input, but works with other inputs such as speech recognition). | +| {{Event("compositionupdate")}} | {{DOMxRef("CompositionEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-compositionupdate) | A character is added to a passage of text being composed. | +| {{Event("contextmenu")}} | {{DOMxRef("MouseEvent")}} | [HTML5](https://html.spec.whatwg.org/multipage/forms.html#context-menus) | The right button of the mouse is clicked (before the context menu is displayed). | +| {{Event("copy")}} | {{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}} | [Clipboard](http://www.w3.org/TR/clipboard-apis/#copy-event) | The text selection has been added to the clipboard. | +| {{Event("cut")}} | {{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}} | [Clipboard](http://www.w3.org/TR/clipboard-apis/#cut-event) | The text selection has been removed from the document and added to the clipboard. | +| {{Event("dblclick")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-dblclick) | A pointing device button is clicked twice on an element. | +| {{Event("devicechange")}} | {{DOMxRef("Event")}} | {{SpecName("Media Capture")}} | A media device such as a camera, microphone, or speaker is connected or removed from the system. | +| {{Event("devicemotion")}} | {{DOMxRef("DeviceMotionEvent")}} {{Experimental_Inline}} | [Device Orientation Events](http://dev.w3.org/geo/api/spec-source-orientation.html) | Fresh data is available from a motion sensor. | +| {{Event("deviceorientation")}} | {{DOMxRef("DeviceOrientationEvent")}} {{Experimental_Inline}} | [Device Orientation Events](http://dev.w3.org/geo/api/spec-source-orientation.html) | Fresh data is available from an orientation sensor. | +| {{Event("dischargingtimechange")}} | {{DOMxRef("Event")}} | [Battery status](https://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html) | The `dischargingTime` attribute has been updated. | +| `DOMActivate` {{Deprecated_Inline}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMActivate) | A button, link or state changing element is activated (use {{Event("click")}} instead). | +| [`DOMAttributeNameChanged`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationNameEvent")}} | [DOM L3](http://www.w3.org/TR/2011/WD-DOM-Level-3-Events-20110531/#event-type-DOMAttributeNameChanged) Removed | The name of an attribute changed (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMAttrModified`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified) | The value of an attribute has been modified (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMCharacterDataModified`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMCharacterDataModified) | A text or another [CharacterData](/zh-CN/docs/DOM/CharacterData) has changed (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| {{Event("DOMContentLoaded")}} | {{DOMxRef("Event")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#the-end) | The document has finished loading (but not its dependent resources). | +| [`DOMElementNameChanged`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationNameEvent")}} | [DOM L3](http://www.w3.org/TR/2011/WD-DOM-Level-3-Events-20110531/#event-type-DOMElementNameChanged) Removed | The name of an element changed (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| `DOMFocusIn` {{Deprecated_Inline}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMFocusIn) | An element has received focus (use {{Event("focus")}} or {{Event("focusin")}} instead). | +| `DOMFocusOut` {{Deprecated_Inline}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMFocusOut) | An element has lost focus (use {{Event("blur")}} or {{Event("focusout")}} instead). | +| [`DOMNodeInserted`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted) | A node has been added as a child of another node (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMNodeInsertedIntoDocument`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInsertedIntoDocument) | A node has been inserted into the document (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMNodeRemoved`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved) | A node has been removed from its parent node (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMNodeRemovedFromDocument`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemovedFromDocument) | A node has been removed from the document (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| [`DOMSubtreeModified`](/zh-CN/docs/DOM/Mutation_events) {{Deprecated_Inline}} | {{DOMxRef("MutationEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMSubtreeModified) | A change happened in the document (use [mutation observers](/zh-CN/docs/DOM/MutationObserver) instead). | +| {{Event("drag")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-drag) | An element or text selection is being dragged (every 350ms). | +| {{Event("dragend")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragend) | A drag operation is being ended (by releasing a mouse button or hitting the escape key). | +| {{Event("dragenter")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragenter) | A dragged element or text selection enters a valid drop target. | +| {{Event("dragleave")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragleave) | A dragged element or text selection leaves a valid drop target. | +| {{Event("dragover")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragover) | An element or text selection is being dragged over a valid drop target (every 350ms). | +| {{Event("dragstart")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-dragstart) | The user starts dragging an element or text selection. | +| {{Event("drop")}} | {{DOMxRef("DragEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#event-drop) | An element is dropped on a valid drop target. | +| {{Event("durationchange")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-durationchange) | The `duration` attribute has been updated. | +| {{Event("emptied")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-emptied) | The media has become empty; for example, this event is sent if the media has already been loaded (or partially loaded), and the [`load()`](/zh-CN/docs/XPCOM_Interface_Reference/NsIDOMHTMLMediaElement) method is called to reload it. | +| {{Event("end_(SpeechRecognition)","end")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | The speech recognition service has disconnected. | +| {{Event("end_(SpeechSynthesis)","end")}} {{Experimental_Inline}} | {{DOMxRef("SpeechSynthesisEvent")}} | {{SpecName("Web Speech API")}} | The utterance has finished being spoken. | +| {{Event("ended")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-ended) | Playback has stopped because the end of the media was reached. | +| {{Event("ended_(Web_Audio)", "ended")}} | {{DOMxRef("Event")}} | {{SpecName("Web Audio API")}} | Playback has stopped because the end of the media was reached. | +| {{Event("endEvent")}} | {{DOMxRef("TimeEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | A [SMIL](/zh-CN/docs/SVG/SVG_animation_with_SMIL) animation element ends. | +| {{Event("error")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-error) | A resource failed to load. | +| {{Event("error")}} | {{DOMxRef("ProgressEvent")}} | [Progress](http://www.w3.org/TR/progress-events/) and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-error) | Progression has failed. | +| {{Event("error")}} | {{DOMxRef("Event")}} | [WebSocket](http://www.w3.org/TR/websockets/) | A WebSocket connection has been closed with prejudice (some data couldn't be sent for example). | +| {{Event("error")}} | {{DOMxRef("Event")}} | [Server Sent Events](http://dev.w3.org/html5/eventsource/) | An event source connection has been failed. | +| {{Event("error")}} | {{DOMxRef("Event")}} | [IndexedDB](http://www.w3.org/TR/IndexedDB/#request-api) | A request caused an error and failed. | +| {{Event("error_(SpeechRecognitionError)","error")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | A speech recognition error occurs. | +| {{Event("error_(SpeechSynthesisError)","error")}} | {{DOMxRef("SpeechSynthesisErrorEvent")}} | {{SpecName('Web Speech API')}} | An error occurs that prevents the utterance from being successfully spoken. | +| {{Event("focus")}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-focus) | An element has received focus (does not bubble). | +| {{Event("focusin")}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-focusIn) | An element is about to receive focus (bubbles). | +| {{Event("focusout")}} | {{DOMxRef("FocusEvent")}} {{Experimental_Inline}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-focusout) | An element is about to lose focus (bubbles). | +| {{Event("fullscreenchange")}} | {{DOMxRef("Event")}} | [Full Screen](https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api) | An element was turned to fullscreen mode or back to normal mode. | +| {{Event("fullscreenerror")}} | {{DOMxRef("Event")}} | [Full Screen](https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#api) | It was impossible to switch to fullscreen mode for technical reasons or because the permission was denied. | +| {{Event("gamepadconnected")}} | {{DOMxRef("GamepadEvent")}} {{Experimental_Inline}} | [Gamepad](http://www.w3.org/TR/gamepad/#the-gamepadconnected-event) | A gamepad has been connected. | +| {{Event("gamepaddisconnected")}} | {{DOMxRef("GamepadEvent")}} {{Experimental_Inline}} | [Gamepad](http://www.w3.org/TR/gamepad/#the-gamepaddisconnected-event) | A gamepad has been disconnected. | +| {{Event("gotpointercapture")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-gotpointercapture-event) | Element receives pointer capture. | +| {{Event("hashchange")}} | {{DOMxRef("HashChangeEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-hashchange) | The fragment identifier of the URL has changed (the part of the URL after the #). | +| {{Event("lostpointercapture")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-lostpointercapture-event) | Element lost pointer capture. | +| {{Event("input")}} | {{DOMxRef("Event")}} | [HTML5](http://www.w3.org/TR/html5/forms.html#common-event-behaviors) | The value of an element changes or the content of an element with the attribute [contenteditable](/zh-CN/docs/DOM/Element.contentEditable) is modified. | +| {{Event("invalid")}} | {{DOMxRef("Event")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#constraint-validation) | A submittable element has been checked and doesn't satisfy its constraints. | +| {{Event("keydown")}} | {{DOMxRef("KeyboardEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-keydown) | A key is pressed down. | +| {{Event("keypress")}} | {{DOMxRef("KeyboardEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-keypress) | A key is pressed down and that key normally produces a character value (use input instead). | +| {{Event("keyup")}} | {{DOMxRef("KeyboardEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-keyup) | A key is released. | +| {{Event("languagechange")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{ SpecName('HTML5.1', '#dom-navigator-languages', 'NavigatorLanguage.languages') }} | The user's preferred languages have changed. | +| {{Event("levelchange")}} | {{DOMxRef("Event")}} | [Battery status](https://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html) | The `level` attribute has been updated. | +| {{Event("load")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-load) | A resource and its dependent resources have finished loading. | +| [`load`]() | {{DOMxRef("ProgressEvent")}} | [Progress](http://www.w3.org/TR/progress-events/) and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-load) | Progression has been successful. | +| {{Event("loadeddata")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-loadeddata) | The first frame of the media has finished loading. | +| {{Event("loadedmetadata")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-loadedmetadata) | The metadata has been loaded. | +| {{Event("loadend")}} | {{DOMxRef("ProgressEvent")}} | [Progress](http://www.w3.org/TR/progress-events/) and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-loadend) | Progress has stopped (after "error", "abort" or "load" have been dispatched). | +| {{Event("loadstart")}} | {{DOMxRef("ProgressEvent")}} | [Progress ](http://www.w3.org/TR/progress-events/)and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-loadstart) | Progress has begun. | +| {{Event("mark")}} {{Experimental_Inline}} | {{DOMxRef("SpeechSynthesisEvent")}} | {{SpecName('Web Speech API')}} | The spoken utterance reaches a named SSML "mark" tag. | +| [`message`](/zh-CN/docs/Web/Reference/Events/message_websocket) | {{DOMxRef("MessageEvent")}} | [WebSocket](http://www.w3.org/TR/websockets/) | A message is received through a WebSocket. | +| [`message`](/zh-CN/docs/Web/Reference/Events/message_webworker) | {{DOMxRef("MessageEvent")}} | [Web Workers](http://www.w3.org/TR/workers/#communicating-with-a-dedicated-worker) | A message is received from a Web Worker. | +| [`message`](/zh-CN/docs/Web/Reference/Events/message_webmessaging) | {{DOMxRef("MessageEvent")}} | [Web Messaging](http://www.w3.org/TR/webmessaging/) | A message is received from a child (i)frame or a parent window. | +| [`message`](/zh-CN/docs/Web/Reference/Events/message_serversentevents) | {{DOMxRef("MessageEvent")}} | [Server Sent Events](http://dev.w3.org/html5/eventsource/) | A message is received through an event source. | +| {{Event("messageerror")}} | {{DOMxRef("MessageEvent")}} | {{DOMxRef("MessagePort")}}, [Web Workers](/zh-CN/docs/Web/API/Web_Workers_API), [Broadcast Channel](/zh-CN/docs/Web/API/Broadcast_Channel_API), {{DOMxRef("Window")}} | A message error is raised when a message is received by an object. | +| {{Event("message_(ServiceWorker)","message")}} {{Experimental_Inline}} | {{DOMxRef("ServiceWorkerMessageEvent")}} or {{DOMxRef("ExtendableMessageEvent")}}, depending on context. | [Service Workers](/zh-CN/docs/Web/API/Service_Worker_API) | A message is received from a service worker, or a message is received in a service worker from another context. | +| {{Event("mousedown")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mousedown) | A pointing device button (usually a mouse) is pressed on an element. | +| {{Event("mouseenter")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseenter) | A pointing device is moved onto the element that has the listener attached. | +| {{Event("mouseleave")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseleave) | A pointing device is moved off the element that has the listener attached. | +| {{Event("mousemove")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mousemove) | A pointing device is moved over an element. | +| {{Event("mouseout")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseout) | A pointing device is moved off the element that has the listener attached or off one of its children. | +| {{Event("mouseover")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseover) | A pointing device is moved onto the element that has the listener attached or onto one of its children. | +| {{Event("mouseup")}} | {{DOMxRef("MouseEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-mouseup) | A pointing device button is released over an element. | +| {{Event("nomatch")}} {{Experimental_Inline}} | {{DOMxRef("SpeechRecognitionEvent")}} | {{SpecName('Web Speech API')}} | The speech recognition service returns a final result with no significant recognition. | +| {{Event("notificationclick")}} | {{DOMxRef("NotificationEvent")}} {{Experimental_Inline}} | {{SpecName('Web Notifications','#dom-serviceworkerglobalscope-onnotificationclick','onnotificationclick')}} | A system notification spawned by {{DOMxRef("ServiceWorkerRegistration.showNotification()")}} has been clicked. | +| {{Event("offline")}} | {{DOMxRef("Event")}} | [HTML5 offline](http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#event-offline) | The browser has lost access to the network. | +| {{Event("online")}} | {{DOMxRef("Event")}} | [HTML5 offline](http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#event-online) | The browser has gained access to the network (but particular websites might be unreachable). | +| [`open`](/zh-CN/docs/Web/Reference/Events/open_websocket) | {{DOMxRef("Event")}} | [WebSocket](http://www.w3.org/TR/websockets/) | A WebSocket connection has been established. | +| [`open`](/zh-CN/docs/Web/Reference/Events/open_serversentevents) | {{DOMxRef("Event")}} | [Server Sent Events](http://dev.w3.org/html5/eventsource/) | An event source connection has been established. | +| {{Event("orientationchange")}} | {{DOMxRef("Event")}} | [Screen Orientation](http://www.w3.org/TR/screen-orientation/) | The orientation of the device (portrait/landscape) has changed | +| {{Event("pagehide")}} | {{DOMxRef("PageTransitionEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-pagehide) | A session history entry is being traversed from. | +| {{Event("pageshow")}} | {{DOMxRef("PageTransitionEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-pageshow) | A session history entry is being traversed to. | +| {{Event("paste")}} | {{DOMxRef("ClipboardEvent")}} {{Experimental_Inline}} | [Clipboard](http://www.w3.org/TR/clipboard-apis/#paste-event) | Data has been transferred from the system clipboard to the document. | +| {{Event("pause")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-pause) | Playback has been paused. | +| {{Event("pause_(SpeechSynthesis)", "pause")}} {{Experimental_Inline}} | {{DOMxRef("SpeechSynthesisEvent")}} | {{SpecName('Web Speech API')}} | The utterance is paused part way through. | +| {{Event("pointercancel")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointercancel-event) | The pointer is unlikely to produce any more events. | +| {{Event("pointerdown")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerdown-event) | The pointer enters the active buttons state. | +| {{Event("pointerenter")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerenter-event) | Pointing device is moved inside the hit-testing boundary. | +| {{Event("pointerleave")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerleave-event) | Pointing device is moved out of the hit-testing boundary. | +| {{Event("pointerlockchange")}} | {{DOMxRef("Event")}} | [Pointer Lock](http://www.w3.org/TR/pointerlock/#pointerlockchange-and-pointerlockerror-events) | The pointer was locked or released. | +| {{Event("pointerlockerror")}} | {{DOMxRef("Event")}} | [Pointer Lock](http://www.w3.org/TR/pointerlock/#pointerlockchange-and-pointerlockerror-events) | It was impossible to lock the pointer for technical reasons or because the permission was denied. | +| {{Event("pointermove")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointermove-event) | The pointer changed coordinates. | +| {{Event("pointerout")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerout-event) | The pointing device moved out of hit-testing boundary or leaves detectable hover range. | +| {{Event("pointerover")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerover-event) | The pointing device is moved into the hit-testing boundary. | +| {{Event("pointerup")}} | {{DOMxRef("PointerEvent")}} | [Pointer Events](http://www.w3.org/TR/pointerevents/#the-pointerup-event) | The pointer leaves the active buttons state. | +| {{Event("play")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-play) | Playback has begun. | +| {{Event("playing")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-playing) | Playback is ready to start after having been paused or delayed due to lack of data. | +| {{Event("popstate")}} | {{DOMxRef("PopStateEvent")}} | [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#event-popstate) | A session history entry is being navigated to (in certain cases). | +| {{Event("progress")}} | {{DOMxRef("ProgressEvent")}} | [Progress](http://www.w3.org/TR/progress-events/) and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-progress) | In progress. | +| {{Event("push")}} | {{DOMxRef("PushEvent")}} {{Experimental_Inline}} | {{SpecName("Push API")}} | A [Service Worker](/zh-CN/docs/Web/API/Service_Worker_API) has received a push message. | +| {{Event("pushsubscriptionchange")}} | {{DOMxRef("PushEvent")}} {{Experimental_Inline}} | {{SpecName("Push API")}} | A [PushSubscription](/zh-CN/docs/Web/API/PushSubscription) has expired. | +| {{Event("ratechange")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-ratechange) | The playback rate has changed. | +| {{Event("readystatechange")}} | {{DOMxRef("Event")}} | HTML5 and [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-readystatechange) | The readyState attribute of a document has changed. | +| {{Event("repeatEvent")}} | {{DOMxRef("TimeEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | A [SMIL](/zh-CN/docs/SVG/SVG_animation_with_SMIL) animation element is repeated. | +| {{Event("reset")}} | {{DOMxRef("Event")}} | [DOM L2](http://www.w3.org/TR/DOM-Level-2-Events/events.html), [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-0#resetting-a-form) | A form is reset. | +| {{Event("resize")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-resize) | The document view has been resized. | +| {{Event("resourcetimingbufferfull")}} | {{DOMxRef("Performance")}} | [Resource Timing](https://w3c.github.io/resource-timing/#dom-performance-onresourcetimingbufferfull) | The browser's resource timing buffer is full. | +| {{Event("result")}} {{Experimental_Inline}} | {{DOMxRef("SpeechRecognitionEvent")}} {{Experimental_Inline}} | {{SpecName('Web Speech API')}} | The speech recognition service returns a result — a word or phrase has been positively recognized and this has been communicated back to the app. | +| {{Event("resume")}} {{Experimental_Inline}} | {{DOMxRef("SpeechSynthesisEvent")}} {{Experimental_Inline}} | {{SpecName('Web Speech API')}} | A paused utterance is resumed. | +| {{Event("scroll")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-scroll) | The document view or an element has been scrolled. | +| {{Event("seeked")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-seeked) | A _seek_ operation completed. | +| {{Event("seeking")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-seeking) | A _seek_ operation began. | +| {{Event("select")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-select) | Some text is being selected. | +| {{Event("selectstart")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{ SpecName('Selection API')}} | A selection just started. | +| {{Event("selectionchange")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{ SpecName('Selection API')}} | The selection in the document has been changed. | +| {{Event("show")}} | {{DOMxRef("MouseEvent")}} | [HTML5](http://www.w3.org/TR/html5/interactive-elements.html#context-menus) | A contextmenu event was fired on/bubbled to an element that has a [contextmenu](/zh-CN/docs/DOM/element.contextmenu) attribute | +| {{Event("slotchange")}} | {{DOMxRef("Event")}} | {{ SpecName('DOM WHATWG')}} | The node contents of a {{DOMxRef("HTMLSlotElement")}} ({{htmlelement("slot")}}) have changed. | +| {{Event("soundend")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | Any sound — recognisable speech or not — has stopped being detected. | +| {{Event("soundstart")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | Any sound — recognisable speech or not — has been detected. | +| {{Event("speechend")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | Speech recognised by the speech recognition service has stopped being detected. | +| {{Event("speechstart")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | Sound that is recognised by the speech recognition service as speech has been detected. | +| {{Event("stalled")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-stalled) | The user agent is trying to fetch media data, but data is unexpectedly not forthcoming. | +| {{Event("start_(SpeechRecognition)","start")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | The speech recognition service has begun listening to incoming audio with intent to recognize grammars associated with the current `SpeechRecognition`. | +| {{Event("start_(SpeechSynthesis)","start")}} | {{DOMxRef("SpeechSynthesisEvent")}} | {{SpecName('Web Speech API')}} | The utterance has begun to be spoken. | +| {{Event("storage")}} | {{DOMxRef("StorageEvent")}} | [Web Storage](http://www.w3.org/TR/webstorage/#the-storage-event) | A storage area ([localStorage](/zh-CN/docs/DOM/Storage#localStorage) or [sessionStorage](/zh-CN/docs/DOM/Storage#sessionStorage)) has changed. | +| {{Event("submit")}} | {{DOMxRef("Event")}} | [DOM L2](http://www.w3.org/TR/DOM-Level-2-Events/events.html), [HTML5](http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#form-submission-algorithm) | A form is submitted. | +| [`success`](/zh-CN/docs/Web/Reference/Events/success_indexedDB) | {{DOMxRef("Event")}} | [IndexedDB](http://www.w3.org/TR/IndexedDB/#request-api) | A request successfully completed. | +| {{Event("suspend")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-suspend) | Media data loading has been suspended. | +| {{Event("SVGAbort")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | Page loading has been stopped before the [SVG](/zh-CN/docs/SVG) was loaded. | +| {{Event("SVGError")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An error has occurred before the [SVG](/zh-CN/docs/SVG) was loaded. | +| {{Event("SVGLoad")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An [SVG](/zh-CN/docs/SVG) document has been loaded and parsed. | +| {{Event("SVGResize")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An [SVG](/zh-CN/docs/SVG) document is being resized. | +| {{Event("SVGScroll")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An [SVG](/zh-CN/docs/SVG) document is being scrolled. | +| {{Event("SVGUnload")}} | {{DOMxRef("SVGEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An [SVG](/zh-CN/docs/SVG) document has been removed from a window or frame. | +| {{Event("SVGZoom")}} | {{DOMxRef("SVGZoomEvent")}} | [SVG](http://www.w3.org/TR/SVG/interact.html#SVGEvents) | An [SVG](/zh-CN/docs/SVG) document is being zoomed. | +| {{Event("timeout")}} | {{DOMxRef("ProgressEvent")}} | [XMLHttpRequest](http://www.w3.org/TR/XMLHttpRequest/#event-xhr-timeout) | | +| {{Event("timeupdate")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-timeupdate) | The time indicated by the `currentTime` attribute has been updated. | +| {{Event("touchcancel")}} | {{DOMxRef("TouchEvent")}} | [Touch Events](http://www.w3.org/TR/touch-events/) | A touch point has been disrupted in an implementation-specific manners (too many touch points for example). | +| {{Event("touchend")}} | {{DOMxRef("TouchEvent")}} | [Touch Events](http://www.w3.org/TR/touch-events/#the-touchend-event) | A touch point is removed from the touch surface. | +| {{Event("touchmove")}} | {{DOMxRef("TouchEvent")}} | [Touch Events](http://www.w3.org/TR/touch-events/#the-touchmove-event) | A touch point is moved along the touch surface. | +| {{Event("touchstart")}} | {{DOMxRef("TouchEvent")}} | [Touch Events](http://www.w3.org/TR/touch-events/#the-touchstart---------event) | A touch point is placed on the touch surface. | +| {{Event("transitionend")}} | {{DOMxRef("TransitionEvent")}} {{Experimental_Inline}} | [CSS Transitions](http://www.w3.org/TR/css3-transitions/#transition-events) | A [CSS transition](/zh-CN/docs/CSS/CSS_transitions) has completed. | +| {{Event("unload")}} | {{DOMxRef("UIEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-unload) | The document or a dependent resource is being unloaded. | +| [`upgradeneeded`](/zh-CN/docs/Web/Reference/Events/upgradeneeded_indexedDB) | | [IndexedDB](http://www.w3.org/TR/IndexedDB/#request-api) | An attempt was made to open a database with a version number higher than its current version. A `versionchange` transaction has been created. | +| {{Event("userproximity")}} | {{DOMxRef("UserProximityEvent")}} {{Experimental_Inline}} | {{SpecName("Proximity Events")}} | Fresh data is available from a proximity sensor (indicates whether the nearby object is `near` the device or not). | +| {{Event("voiceschanged")}} {{Experimental_Inline}} | {{DOMxRef("Event")}} | {{SpecName('Web Speech API')}} | The list of {{DOMxRef("SpeechSynthesisVoice")}} objects that would be returned by the {{DOMxRef("SpeechSynthesis.getVoices()")}} method has changed (when the {{Event("voiceschanged")}} event fires.) | +| [`versionchange`](/zh-CN/docs/Web/Reference/Events/versionchange_indexedDB) | | [IndexedDB](http://www.w3.org/TR/IndexedDB/#database-interface) | A `versionchange` transaction completed. | +| {{Event("visibilitychange")}} | {{DOMxRef("Event")}} | [Page visibility](http://www.w3.org/TR/page-visibility/#sec-visibilitychange-event) | The content of a tab has become visible or has been hidden. | +| {{Event("volumechange")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-volumechange) | The volume has changed. | +| {{Event("waiting")}} | {{DOMxRef("Event")}} | [HTML5 media](http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#event-media-waiting) | Playback has stopped because of a temporary lack of data. | +| {{Event("wheel")}} | {{DOMxRef("WheelEvent")}} | [DOM L3](http://www.w3.org/TR/DOM-Level-3-Events/#event-type-wheel) | A wheel button of a pointing device is rotated in any direction. | + +## 非标准事件 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Event NameEvent TypeSpecificationFired when...
{{Event("afterscriptexecute")}}{{DOMxRef("Event")}}Mozilla SpecificA script has been executed.
{{Event("beforescriptexecute")}}{{DOMxRef("Event")}}Mozilla SpecificA script is about to be executed.
{{Event("beforeinstallprompt")}}{{DOMxRef("Event")}}Chrome specificA user is prompted to save a web site to a home screen on mobile.
{{Event("cardstatechange")}}Firefox OS specific + The {{DOMxRef("MozMobileConnection.cardState")}} + property changes value. +
{{Event("change")}}{{DOMxRef("DeviceStorageChangeEvent")}}Firefox OS specific + This event is triggered each time a file is created, modified or deleted + on a given storage area. +
{{Event("connectionInfoUpdate")}}Firefox OS specific + The informations about the signal strength and the link speed have been + updated. +
{{Event("cfstatechange")}}Firefox OS specificThe call forwarding state changes.
{{Event("datachange")}}Firefox OS specific + The {{DOMxRef("MozMobileConnection.data")}} object changes + values. +
{{Event("dataerror")}}Firefox OS specific + The {{DOMxRef("MozMobileConnection.data")}} object receive + an error from the RIL. +
{{Event("DOMMouseScroll")}}{{Deprecated_Inline}}Mozilla specific + The wheel button of a pointing device is rotated (detail attribute is a + number of lines). (use {{Event("wheel")}} instead) +
dragdrop {{Deprecated_Inline}}DragEventMozilla specificAn element is dropped (use {{Event("drop")}} instead).
dragexit {{Deprecated_Inline}}DragEventMozilla specific + A drag operation is being ended(use {{Event("dragend")}} + instead). +
draggesture {{Deprecated_Inline}}DragEventMozilla specific + The user starts dragging an element or text selection (use + {{Event("dragstart")}} instead). +
{{Event("icccardlockerror")}}Firefox OS specific + the {{DOMxRef("MozMobileConnection.unlockCardLock()")}} + or {{DOMxRef("MozMobileConnection.setCardLock()")}} + methods fails. +
{{Event("iccinfochange")}}Firefox OS specific + The {{DOMxRef("MozMobileConnection.iccInfo")}} object + changes. +
{{Event("localized")}} + Mozilla Specific + The page has been localized using data-l10n-* attributes.
{{Event("mousewheel")}} {{Deprecated_Inline}} + IE invented + The wheel button of a pointing device is rotated.
{{Event("MozAudioAvailable")}}{{DOMxRef("Event")}}Mozilla specific + The audio buffer is full and the corresponding raw samples are + available. +
+ MozBeforeResize + {{Deprecated_Inline}} + Mozilla specificA window is about to be resized.
{{Event("mozbrowseractivitydone")}} + Firefox OS + Browser API-specific + + Sent when some activity has been completed (complete description TBD.) +
{{Event("mozbrowserasyncscroll")}} + Firefox OS + Browser API-specific + + Sent when the scroll position within a browser {{HTMLElement("iframe")}} changes. +
{{Event("mozbrowseraudioplaybackchange")}} + Firefox OS + Browser API-specific + + Sent when audio starts or stops playing within the browser + {{HTMLElement("iframe")}} content. +
{{Event("mozbrowsercaretstatechanged")}} + Firefox OS + Browser API-specific + + Sent when the text selected inside the browser + {{HTMLElement("iframe")}} content changes. +
{{Event("mozbrowserclose")}} + Firefox OS + Browser API-specific + + Sent when window.close() is called within a browser + {{HTMLElement("iframe")}}. +
{{Event("mozbrowsercontextmenu")}} + Firefox OS + Browser API-specific + + Sent when a browser {{HTMLElement("iframe")}} try to open a + context menu. +
{{Event("mozbrowserdocumentfirstpaint")}} + Firefox OS + Browser API-specific + + Sent when a new paint occurs on any document in the browser + {{HTMLElement("iframe")}}. +
{{Event("mozbrowsererror")}} + Firefox OS + Browser API-specific + + Sent when an error occured while trying to load a content within a + browser iframe +
{{Event("mozbrowserfindchange")}} + Firefox OS + Browser API-specific + + Sent when a search operation is performed on the browser + {{HTMLElement("iframe")}} content (see + HTMLIFrameElement search methods.) +
{{Event("mozbrowserfirstpaint")}} + Firefox OS + Browser API-specific + + Sent when the {{HTMLElement("iframe")}} paints content for the + first time (this doesn't include the initial paint from + about:blank.) +
{{Event("mozbrowsericonchange")}} + Firefox OS + Browser API-specific + Sent when the favicon of a browser iframe changes.
{{Event("mozbrowserlocationchange")}} + Firefox OS + Browser API-specific + Sent when an browser iframe's location changes.
{{Event("mozbrowserloadend")}} + Firefox OS + Browser API-specific + Sent when the browser iframe has finished loading all its assets.
{{Event("mozbrowserloadstart")}} + Firefox OS + Browser API-specific + Sent when the browser iframe starts to load a new page.
{{Event("mozbrowsermanifestchange")}} + Firefox OS + Browser API-specific + + Sent when a the path to the app manifest changes, in the case of a + browser {{HTMLElement("iframe")}} with an open web app embedded + in it. +
{{Event("mozbrowsermetachange")}} + Firefox OS + Browser API-specific + + Sent when a {{htmlelement("meta")}} elelment is added to, + removed from or changed in the browser + {{HTMLElement("iframe")}}'s content. +
{{Event("mozbrowseropensearch")}} + Firefox OS + Browser API-specific + Sent when a link to a search engine is found.
{{Event("mozbrowseropentab")}} + Firefox OS + Browser API-specific + + Sent when a new tab is opened within a browser + {{HTMLElement("iframe")}} as a result of the user issuing a + command to open a link target in a new tab (for example + ctrl/cmd + click.) +
{{Event("mozbrowseropenwindow")}} + Firefox OS + Browser API-specific + + Sent when {{DOMxRef("window.open()")}} is called within a + browser iframe. +
{{Event("mozbrowserresize")}} + Firefox OS + Browser API-specific + + Sent when the browser {{HTMLElement("iframe")}}'s window size has + changed. +
{{Event("mozbrowserscroll")}} + Firefox OS + Browser API-specific + + Sent when the browser {{HTMLElement("iframe")}} content scrolls. +
{{Event("mozbrowserscrollareachanged")}} + Firefox OS + Browser API-specific + + Sent when the available scrolling area in the browser + {{HTMLElement("iframe")}} changes. This can occur on resize and + when the page size changes (while loading for example.) +
{{Event("mozbrowserscrollviewchange")}} + Firefox OS + Browser API-specific + Sent when asynchronous scrolling (i.e. APCZ) starts or stops.
{{Event("mozbrowsersecuritychange")}} + Firefox OS + Browser API-specific + Sent when the SSL state changes within a browser iframe.
{{Event("mozbrowserselectionstatechanged")}} + Firefox OS + Browser API-specific + + Sent when the text selected inside the browser + {{HTMLElement("iframe")}} content changes. Note that this is + deprecated, and newer implementations use + {{Event("mozbrowsercaretstatechanged")}} instead. +
{{Event("mozbrowsershowmodalprompt")}} + Firefox OS + Browser API-specific + + Sent when {{DOMxRef("window.alert","alert()")}}, + {{DOMxRef("window.confirm","confirm()")}} or + {{DOMxRef("window.prompt","prompt()")}} are called within a + browser iframe +
{{Event("mozbrowsertitlechange")}} + Firefox OS + Browser API-specific + Sent when the document.title changes within a browser iframe.
+ {{Event("mozbrowserusernameandpasswordrequired")}} + + Firefox OS + Browser API-specific + Sent when an HTTP authentification is requested.
{{Event("mozbrowservisibilitychange")}} + Firefox OS + Browser API-specific + + Sent when the visibility state of the current browser iframe + {{HTMLElement("iframe")}} changes, for example due to a call to + {{DOMxRef("HTMLIFrameElement.setVisible","setVisible()")}}. +
{{Event("MozGamepadButtonDown")}}To be specifiedA gamepad button is pressed down.
{{Event("MozGamepadButtonUp")}}To be specifiedA gamepad button is released.
+ {{Event("MozMousePixelScroll")}} + {{Deprecated_Inline}} + Mozilla specific + The wheel button of a pointing device is rotated (detail attribute is a + number of pixels). (use wheel instead) +
{{Event("MozOrientation")}} {{Deprecated_Inline}}Mozilla specific + Fresh data is available from an orientation sensor (see + deviceorientation). +
{{Event("MozScrolledAreaChanged")}}{{DOMxRef("UIEvent")}}Mozilla specificThe document view has been scrolled or resized.
{{Event("moztimechange")}}Mozilla specificThe time of the device has been changed.
+ MozTouchDown + {{Deprecated_Inline}} + Mozilla specific + A touch point is placed on the touch surface (use touchstart instead). +
+ MozTouchMove + {{Deprecated_Inline}} + Mozilla specific + A touch point is moved along the touch surface (use touchmove instead). +
+ MozTouchUp + {{Deprecated_Inline}} + Mozilla specific + A touch point is removed from the touch surface (use touchend instead). +
{{Event("alerting")}}{{DOMxRef("CallEvent")}}To be specifiedThe correspondent is being alerted (his/her phone is ringing).
{{Event("busy")}}{{DOMxRef("CallEvent")}}To be specifiedThe line of the correspondent is busy.
{{Event("callschanged")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been added or removed from the list of current calls.
+ onconnected + {{Event("connected")}} + {{DOMxRef("CallEvent")}}To be specifiedA call has been connected.
{{Event("connecting")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to connect.
{{Event("delivered")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been successfully delivered.
{{Event("dialing")}}{{DOMxRef("CallEvent")}}To be specifiedThe number of a correspondent has been dialed.
{{Event("disabled")}}Firefox OS specificWifi has been disabled on the device.
{{Event("disconnected")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been disconnected.
{{Event("disconnecting")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to disconnect.
{{Event("enabled")}}Firefox OS specificWifi has been enabled on the device.
{{Event("error_(Telephony)","error")}}{{DOMxRef("CallEvent")}}To be specifiedAn error occurred.
{{Event("held")}}{{DOMxRef("CallEvent")}}To be specifiedA call has been held.
{{Event("holding")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to be held.
{{Event("incoming")}}{{DOMxRef("CallEvent")}}To be specifiedA call is being received.
{{Event("received")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been received.
{{Event("resuming")}}{{DOMxRef("CallEvent")}}To be specifiedA call is about to resume.
{{Event("sent")}}{{DOMxRef("SMSEvent")}}To be specifiedAn SMS has been sent.
{{Event("statechange")}}{{DOMxRef("CallEvent")}}To be specifiedThe state of a call has changed.
{{Event("statuschange")}}Firefox OS specificThe status of the Wifi connection changed.
{{Event("overflow")}}{{DOMxRef("UIEvent")}}Mozilla specific + An element has been overflowed by its content or has been rendered for + the first time in this state (only works for elements styled with + overflow != visible). +
{{Event("smartcard-insert")}}Mozilla specific + A smartcard has been + inserted. +
{{Event("smartcard-remove")}}Mozilla specific + A smartcard has been + removed. +
{{Event("stkcommand")}}Firefox OS specific + The STK Proactive Command + is issued from ICC. +
{{Event("stksessionend")}}Firefox OS specific + The STK Session is + terminated by ICC. +
{{Event("touchenter")}}{{DOMxRef("TouchEvent")}} + Touch Events + Removed +
{{Event("touchleave")}}{{DOMxRef("TouchEvent")}} + Touch Events + Removed +
{{Event("underflow")}}{{DOMxRef("UIEvent")}}Mozilla specific + An element is no longer overflowed by its content (only works for + elements styled with overflow != visible). +
uploadprogress {{Deprecated_Inline}}{{DOMxRef("ProgressEvent")}}Mozilla SpecificUpload is in progress (see {{Event("progress")}}).

{{Event("ussdreceived")}}

Firefox OS specific + A new + USSD + message is received +
{{Event("voicechange")}}Firefox OS specific + The {{DOMxRef("MozMobileConnection.voice")}} object changes + values. +
{{Event("msContentZoom")}}Microsoft specific
{{Event("MSManipulationStateChanged")}}Microsoft specific
{{Event("MSPointerHover")}} {{Deprecated_Inline}}Microsoft specific
+ +## Mozilla 特定事件 + +> **备注:** 这些事件不会暴露给 Web 内容使用,只能在 chrome 内容的上下文中使用。 + +### XUL 事件 + +| Event Name | Event Type | Specification | Fired when... | +| ----------------------------------------------------- | ------------ | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | +| {{Event("broadcast")}} | | [XUL](/zh-CN/docs/XUL/Tutorial/Broadcasters_and_Observers#Broadcast_event) | An `observer` noticed a change to the attributes of a watched broadcaster. | +| {{Event("CheckboxStateChange")}} | | XUL | The state of a `checkbox` has been changed either by a user action or by a script (useful for accessibility). | +| [close](/zh-CN/docs/Web/Reference/Events/close_event) | | XUL | The close button of the window has been clicked. | +| {{Event("command")}} | | XUL | An element has been activated. | +| {{Event("commandupdate")}} | | XUL | A command update occurred on a `commandset` element. | +| {{Event("DOMMenuItemActive")}} | | XUL | A menu or menuitem has been hovered or highlighted. | +| {{Event("DOMMenuItemInactive")}} | | _XUL_ | A menu or menuitem is no longer hovered or highlighted. | +| {{Event("popuphidden")}} | `PopupEvent` | [_XUL_](/zh-CN/docs/XUL/PopupGuide/PopupEvents) | A menupopup, panel or tooltip has been hidden. | +| {{Event("popuphiding")}} | `PopupEvent` | [_XUL_](/zh-CN/docs/XUL/PopupGuide/PopupEvents) | A menupopup, panel or tooltip is about to be hidden. | +| {{Event("popupshowing")}} | `PopupEvent` | [_XUL_](/zh-CN/docs/XUL/PopupGuide/PopupEvents) | A menupopup, panel or tooltip is about to become visible. | +| {{Event("popupshown")}} | `PopupEvent` | [_XUL_](/zh-CN/docs/XUL/PopupGuide/PopupEvents) | A menupopup, panel or tooltip has become visible. | +| {{Event("RadioStateChange")}} | | XUL | The state of a `radio` has been changed either by a user action or by a script (useful for accessibility). | +| {{Event("ValueChange")}} | | XUL | The value of an element has changed (a progress bar for example, useful for accessibility). | + +### 附加组件特定事件 + +| Event Name | Event Type | Specification | Fired when... | +| ----------------------------------------------------------------------------------- | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------- | +| [MozSwipeGesture](/zh-CN/docs/Web/Reference/Events/MozSwipeGesture) | | _Addons specific_ | A touch point is swiped across the touch surface | +| [MozMagnifyGestureStart](/zh-CN/docs/Web/Reference/Events/MozMagnifyGestureStart) | | _Addons specific_ | Two touch points start to move away from each other. | +| [MozMagnifyGestureUpdate](/zh-CN/docs/Web/Reference/Events/MozMagnifyGestureUpdate) | | _Addons specific_ | Two touch points move away from each other (after a MozMagnifyGestureStart). | +| [MozMagnifyGesture](/zh-CN/docs/Web/Reference/Events/MozMagnifyGesture) | | _Addons specific_ | Two touch points moved away from each other (after a sequence of MozMagnifyGestureUpdate). | +| [MozRotateGestureStart](/zh-CN/docs/Web/Reference/Events/MozRotateGestureStart) | | _Addons specific_ | Two touch points start to rotate around a point. | +| [MozRotateGestureUpdate](/zh-CN/docs/Web/Reference/Events/MozRotateGestureUpdate) | | _Addons specific_ | Two touch points rotate around a point (after a MozRotateGestureStart). | +| [MozRotateGesture](/zh-CN/docs/Web/Reference/Events/MozRotateGesture) | | _Addons specific_ | Two touch points rotate around a point (after a sequence of MozRotateGestureUpdate). | +| [MozTapGesture](/zh-CN/docs/Web/Reference/Events/MozTapGesture) | | _Addons specific_ | Two touch points are tapped on the touch surface. | +| [MozPressTapGesture](/zh-CN/docs/Web/Reference/Events/MozPressTapGesture) | | _Addons specific_ | A "press-tap" gesture happened on the touch surface (first finger down, second finger down, second finger up, first finger up). | +| [MozEdgeUIGesture](/zh-CN/docs/Web/Reference/Events/MozEdgeUIGesture) | | _Addons specific_ | A touch point is swiped across the touch surface to invoke the edge UI (Win8 only). | +| [MozAfterPaint](/zh-CN/docs/Web/Reference/Events/MozAfterPaint) | | _Addons specific_ | Content has been repainted. | +| [DOMPopupBlocked](/zh-CN/docs/Web/Reference/Events/DOMPopupBlocked) | | _Addons specific_ | A popup has been blocked | +| [DOMWindowCreated](/zh-CN/docs/Web/Reference/Events/DOMWindowCreated) | | _Addons specific_ | A window has been created. | +| [DOMWindowClose](/zh-CN/docs/Web/Reference/Events/DOMWindowClose) | | _Addons specific_ | A window is about to be closed. | +| [DOMTitleChanged](/zh-CN/docs/Web/Reference/Events/DOMTitleChanged) | | _Addons specifc_ | The title of a window has changed. | +| [DOMLinkAdded](/zh-CN/docs/Web/Reference/Events/DOMLinkAdded) | | _Addons specifc_ | A link has been added a document. | +| [DOMLinkRemoved](/zh-CN/docs/Web/Reference/Events/DOMLinkRemoved) | | _Addons specifc_ | A link has been removed inside from a document. | +| [DOMMetaAdded](/zh-CN/docs/Web/Reference/Events/DOMMetaAdded) | | _Addons specific_ | A `meta` element has been added to a document. | +| [DOMMetaRemoved](/zh-CN/docs/Web/Reference/Events/DOMMetaRemoved) | | _Addons specific_ | A `meta` element has been removed from a document. | +| [DOMWillOpenModalDialog](/zh-CN/docs/Web/Reference/Events/DOMWillOpenModalDialog) | | _Addons specific_ | A modal dialog is about to open. | +| [DOMModalDialogClosed](/zh-CN/docs/Web/Reference/Events/DOMModalDialogClosed) | | _Addons specific_ | A modal dialog has been closed. | +| [DOMAutoComplete](/zh-CN/docs/Web/Reference/Events/DOMAutoComplete) | | _Addons specific_ | The content of an element has been auto-completed. | +| [DOMFrameContentLoaded](/zh-CN/docs/Web/Reference/Events/DOMFrameContentLoaded) | | _Addons specific_ | The frame has finished loading (but not its dependent resources). | +| [AlertActive](/zh-CN/docs/Web/Reference/Events/AlertActive) | | _Addons specific_ | A [`notification`](/zh-CN/docs/XUL/notification) element is shown. | +| [AlertClose](/zh-CN/docs/Web/Reference/Events/AlertClose) | | _Addons specific_ | A [`notification`](/zh-CN/docs/XUL/notification) element is closed. | +| [fullscreen](/zh-CN/docs/Web/Reference/Events/fullscreen) | | _Addons specific_ | Browser fullscreen mode has been entered or left. | +| [sizemodechange](/zh-CN/docs/Web/Reference/Events/sizemodechange) | | _Addons specific_ | Window has entered/left fullscreen mode, or has been minimized/unminimized. | +| [MozEnteredDomFullscreen](/zh-CN/docs/Web/Reference/Events/MozEnteredDomFullscreen) | | _Addons specific_ | [DOM fullscreen](/zh-CN/docs/DOM/Using_full-screen_mode) mode has been entered. | +| [SSWindowClosing](/zh-CN/docs/Web/Reference/Events/SSWindowClosing) | | _Addons specific_ | The session store will stop tracking this window. | +| [SSTabClosing](/zh-CN/docs/Web/Reference/Events/SSTabClosing) | | _Addons specific_ | The session store will stop tracking this tab. | +| [SSTabRestoring](/zh-CN/docs/Web/Reference/Events/SSTabRestoring) | | _Addons specific_ | A tab is about to be restored. | +| [SSTabRestored](/zh-CN/docs/Web/Reference/Events/SSTabRestored) | | _Addons specific_ | A tab has been restored. | +| [SSWindowStateReady](/zh-CN/docs/Web/Reference/Events/SSWindowStateReady) | | _Addons specific_ | A window state has switched to "ready". | +| [SSWindowStateBusy](/zh-CN/docs/Web/Reference/Events/SSWindowStateBusy) | | _Addons specific_ | A window state has switched to "busy". | +| [TabOpen](/zh-CN/docs/Web/Reference/Events/TabOpen) | | _Addons specific_ | A tab has been opened. | +| [TabClose](/zh-CN/docs/Web/Reference/Events/TabClose) | | _Addons specific_ | A tab has been closed. | +| [TabSelect](/zh-CN/docs/Web/Reference/Events/TabSelect) | | _Addons specific_ | A tab has been selected. | +| [TabShow](/zh-CN/docs/Web/Reference/Events/TabShow) | | _Addons specific_ | A tab has been shown. | +| [TabHide](/zh-CN/docs/Web/Reference/Events/TabHide) | | _Addons specific_ | A tab has been hidden. | +| [TabPinned](/zh-CN/docs/Web/Reference/Events/TabPinned) | | _Addons specific_ | A tab has been pinned. | +| [TabUnpinned](/zh-CN/docs/Web/Reference/Events/TabUnpinned) | | _Addons specific_ | A tab has been unpinned. | + +### 开发者工具特定事件 + +| Event Name | Event Type | Specification | Fired when... | +| --------------------------------------------------------------------------------------- | ---------- | ------------------- | --------------------------------------------------------------------------------- | +| [CssRuleViewRefreshed](/zh-CN/docs/Web/Reference/Events/CssRuleViewRefreshed) | | _devtools specific_ | The "Rules" view of the style inspector has been updated. | +| [CssRuleViewChanged](/zh-CN/docs/Web/Reference/Events/CssRuleViewChanged) | | _devtools specific_ | The "Rules" view of the style inspector has been changed. | +| [CssRuleViewCSSLinkClicked](/zh-CN/docs/Web/Reference/Events/CssRuleViewCSSLinkClicked) | | _devtools specific_ | A link to a CSS file has been clicked in the "Rules" view of the style inspector. | + +## 规范 + +{{Specifications}} + +## 参见 + +- {{DOMxRef("Event")}} +- [事件开发者指南](/zh-CN/docs/Web/Guide/DOM/Events) diff --git a/files/zh-cn/web/events/orientation_and_motion_data_explained/index.html b/files/zh-cn/web/events/orientation_and_motion_data_explained/index.html deleted file mode 100644 index 23312dece9477b..00000000000000 --- a/files/zh-cn/web/events/orientation_and_motion_data_explained/index.html +++ /dev/null @@ -1,51 +0,0 @@ ---- -title: Orientation 和 motion 数据解释 -slug: Web/Events/Orientation_and_motion_data_explained -translation_of: Web/Events/Orientation_and_motion_data_explained -tags: - - Intermediate - - Mobile - - Motion - - NeedsContent - - Orientation - - páginas_a_traducir - - rotation ---- -

总言

-

当我们要使用 orientation 和 motion 事件时,理解浏览器给我们的相关值是什么意思就显的相当重要了。这篇文章会详细介绍在用的坐标系统并会教你如何全用它们。

-
-

警告: 目前,Firefox 和 Chrome 处理坐标的方式不同。 在使用它们的时候要多加注意。

-
-

坐标系

-

坐标系是一种描述物体位置的系统,它包含三个轴 (X,Y,Z),三个轴共同描述了物体相对于参照物的位置信息。当我们使用 orientation 和 motion 事件时会接触到两种坐标系统。

-

地球坐标系

-

地球坐标系是相对于地心的,也就是说,它的轴是基于重力方向和磁场北方向。我们使用大写的 X,Y,Z 来描述地球坐标系的轴。

- -

设备坐标系

-

设备坐标系是相对于设备中心的。我们使用小写的 x,y,z 来描述它的轴。

-

,axes.png

- -
- 注意:对于手机或平台而言,这里的设备方向总是相对于屏幕的标准方向,大部分是“竖屏”方向。而对于笔记本电脑来说,设备方向是相对于键盘的。如果你想检测设备方向变化来进行补偿调整,你可以使用 orientationchange 事件。
-

旋转 (Rotation)

-

旋转描述的是设备在设备坐标系跟地球坐标系中任意轴上的差异值,用角度表示。

-

Alpha

-

围绕 z 轴旋转设备将使 alpha 角度值发生变化:

-

alpha.png

-

alpha 为 0°时表示设备的顶部正指北极方向,当设备向左旋转时,alpha 将增加。

-

Beta

-

围绕 x 轴旋转,也就是前后旋转,将使 beta 值发生改变:

-

beta.png

-

当 beta 为 0° 时表示设备顶部和底部与地表面的距离是一样的,当设备向前翻转时,beta 递增到 180°,向后翻转递减到-180°。

-

Gamma

-

当围绕 y 轴旋转,也就是左右倾斜设备时,将使 gamma 值发生改变:

-

gamma.png

-

gamma 等于 0°表示设备左右两边与地表面的距离相等,当设备向右翻转时,gamma 递增到 90° ,向左翻转时,递减到-90°。

diff --git a/files/zh-cn/web/events/orientation_and_motion_data_explained/index.md b/files/zh-cn/web/events/orientation_and_motion_data_explained/index.md new file mode 100644 index 00000000000000..b4b80f9a873030 --- /dev/null +++ b/files/zh-cn/web/events/orientation_and_motion_data_explained/index.md @@ -0,0 +1,70 @@ +--- +title: Orientation 和 motion 数据解释 +slug: Web/Events/Orientation_and_motion_data_explained +tags: + - Intermediate + - Mobile + - Motion + - NeedsContent + - Orientation + - páginas_a_traducir + - rotation +translation_of: Web/Events/Orientation_and_motion_data_explained +--- +## 总言 + +当我们要使用 orientation 和 motion 事件时,理解浏览器给我们的相关值是什么意思就显的相当重要了。这篇文章会详细介绍在用的坐标系统并会教你如何全用它们。 + +> **警告:** 目前,Firefox 和 Chrome 处理坐标的方式不同。 在使用它们的时候要多加注意。 + +## 坐标系 + +坐标系是一种描述物体位置的系统,它包含三个轴 (X,Y,Z),三个轴共同描述了物体相对于参照物的位置信息。当我们使用 orientation 和 motion 事件时会接触到两种坐标系统。 + +### 地球坐标系 + +地球坐标系是相对于地心的,也就是说,它的轴是基于重力方向和磁场北方向。我们使用大写的 X,Y,Z 来描述地球坐标系的轴。 + +- X 轴沿着地平面,垂直于 Y 轴,向东为正,向西为负。 +- Y 轴沿着地平面,向北 (北极,不是磁场北) 为正,向南为负。 +- Z 轴垂直于地平面,想象成一条线连接着设备跟地心。背对地心的方向为正,指向地心的方向为负。 + +### 设备坐标系 + +设备坐标系是相对于设备中心的。我们使用小写的 x,y,z 来描述它的轴。 + +![axes.png](axes.png) + +- x 轴沿着屏幕表面,向右为正,向左为负。 +- y 轴沿着屏幕表面,向上为正,向下为负。 +- z 轴垂直屏幕表面或键盘,远离屏幕的方向为正。 + +> **备注:** 注意:对于手机或平台而言,这里的设备方向总是相对于屏幕的标准方向,大部分是“竖屏”方向。而对于笔记本电脑来说,设备方向是相对于键盘的。如果你想检测设备方向变化来进行补偿调整,你可以使用 orientationchange 事件。 + +## 旋转 (Rotation) + +旋转描述的是设备在设备坐标系跟地球坐标系中任意轴上的差异值,用角度表示。 + +### Alpha + +围绕 z 轴旋转设备将使 alpha 角度值发生变化: + +![alpha.png](alpha.png) + +alpha 为 0° 时表示设备的顶部正指北极方向,当设备向左旋转时,alpha 将增加。 + +### Beta + +围绕 x 轴旋转,也就是前后旋转,将使 beta 值发生改变: + +![beta.png](beta2.png) + +当 beta 为 0° 时表示设备顶部和底部与地表面的距离是一样的,当设备向前翻转时,beta 递增到 180°,向后翻转递减到-180°。 + +### Gamma + +当围绕 y 轴旋转,也就是左右倾斜设备时,将使 gamma 值发生改变: + +![gamma.png](gamma.png) + +gamma 等于 0° 表示设备左右两边与地表面的距离相等,当设备向右翻转时,gamma 递增到 90° ,向左翻转时,递减到-90°。 diff --git a/files/zh-cn/web/exslt/index.html b/files/zh-cn/web/exslt/index.html deleted file mode 100644 index ceaf0b42b2d553..00000000000000 --- a/files/zh-cn/web/exslt/index.html +++ /dev/null @@ -1,89 +0,0 @@ ---- -title: EXSLT -slug: Web/EXSLT -tags: - - EXSLT - - NeedsTranslation - - TopicStub - - XSLT - - XSLT_Reference -translation_of: Web/EXSLT ---- -

-{{ XsltRef() }} -EXSLT is a set of extensions to XSLT. There are a number of modules; those that are supported by Firefox are listed below: -

-
Common (exsl) -
Provides basic extension elements and functions. -
Math (math) -
Provides routines for comparing nodes. -
Regular expressions (regexp) -
Provides facilities for using regular expressions in JavaScript syntax. -
Sets (set) -
Provides routines for manipulating sets. -
Strings (str) -
Provides functions for string manipulation. -
-

Using EXSLT

-

To use an EXSLT function, you need to declare the namespace the function is in, and then use the appropriate prefix when calling the function. For example, to use the regular expressions package: -

-
<xsl:stylesheet version="1.0"
-                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                xmlns:regexp="http://exslt.org/regular-expressions">
-  <xsl:template match="/">
-    ...
-    <xsl:value-of select="regexp:replace(/root/@value, 'before', 'gi', 'AFTER')"/>
-    ...
-  </xsl:template>
-
-</xsl:stylesheet>
-
-

Common

-

The EXSLT Common package provides basic functions that expand upon the capabilities of XSLT. The namespace for the Common package is http://exslt.org/common. -

-

Functions

- -

Math

-

The EXSLT Math package provides functions for working with numeric values and comparing nodes. The namespace for the Math package is http://exslt.org/math. -

-

Functions

- -

Regular expressions

-

The EXSLT Regular Expressions package provides functions that allow testing, matching, and replacing text using JavaScript style regular expressions. -

The EXSLT Regular Expressions namespace is http://exslt.org/regular-expressions. -

-

Functions

- -

Sets

-

The EXSLT Sets package offers functions that let you perform set manipulation. The namespace for these functions is http://exslt.org/sets. -

-

Functions

- -

Strings

-

The EXSLT Strings package provides functions that allow the manipulation of strings. The namespace for the Strings package is http://exslt.org/strings. -

-

Functions

- -

See also

- -


-

diff --git a/files/zh-cn/web/exslt/index.md b/files/zh-cn/web/exslt/index.md new file mode 100644 index 00000000000000..1f202bda64b4a2 --- /dev/null +++ b/files/zh-cn/web/exslt/index.md @@ -0,0 +1,100 @@ +--- +title: EXSLT +slug: Web/EXSLT +tags: + - EXSLT + - NeedsTranslation + - TopicStub + - XSLT + - XSLT_Reference +translation_of: Web/EXSLT +--- +{{ XsltRef() }} +EXSLT is a set of extensions to [XSLT](en/XSLT). There are a number of modules; those that are supported by Firefox are listed below: + +- [Common](#Common) (`exsl`) + - : Provides basic extension elements and functions. +- [Math](#Math) (`math`) + - : Provides routines for comparing nodes. +- [Regular expressions](#Regular_expressions) (`regexp`) + - : Provides facilities for using regular expressions in JavaScript syntax. +- [Sets](#Sets) (`set`) + - : Provides routines for manipulating sets. +- [Strings](#Strings) (`str`) + - : Provides functions for string manipulation. + +### Using EXSLT + +To use an EXSLT function, you need to declare the namespace the function is in, and then use the appropriate prefix when calling the function. For example, to use the regular expressions package: + +```xml + + + ... + + ... + + + +``` + +### Common + +The EXSLT Common package provides basic functions that expand upon the capabilities of XSLT. The namespace for the Common package is `http://exslt.org/common`. + +#### Functions + +- [exsl:node-set](en/EXSLT/exsl/node-set) +- [exsl:object-type](en/EXSLT/exsl/object-type) + +### Math + +The EXSLT Math package provides functions for working with numeric values and comparing nodes. The namespace for the Math package is `http://exslt.org/math`. + +#### Functions + +- [math:highest](en/EXSLT/math/highest) +- [math:lowest](en/EXSLT/math/lowest) +- [math:max](en/EXSLT/math/max) +- [math:min](en/EXSLT/math/min) + +### Regular expressions + +The EXSLT Regular Expressions package provides functions that allow testing, matching, and replacing text using JavaScript style regular expressions. + +The EXSLT Regular Expressions namespace is `http://exslt.org/regular-expressions`. + +#### Functions + +- [regexp:match](en/EXSLT/regexp/match) +- [regexp:replace](en/EXSLT/regexp/replace) +- [regexp:test](en/EXSLT/regexp/test) + +### Sets + +The EXSLT Sets package offers functions that let you perform set manipulation. The namespace for these functions is `http://exslt.org/sets`. + +#### Functions + +- [set:difference](en/EXSLT/set/difference) +- [set:distinct](en/EXSLT/set/distinct) +- [set:intersection](en/EXSLT/set/intersection) +- [set:has-same-node](en/EXSLT/set/has-same-node) +- [set:leading](en/EXSLT/set/leading) +- [set:trailing](en/EXSLT/set/trailing) + +### Strings + +The EXSLT Strings package provides functions that allow the manipulation of strings. The namespace for the Strings package is `http://exslt.org/strings`. + +#### Functions + +- [str:concat](en/EXSLT/str/concat) +- [str:split](en/EXSLT/str/split) +- [str:tokenize](en/EXSLT/str/tokenize) + +### See also + +- [EXSLT web site](http://www.exslt.org/) diff --git a/files/zh-cn/web/exslt/regexp/match/index.html b/files/zh-cn/web/exslt/regexp/match/index.html deleted file mode 100644 index 0c4237e31d1c6d..00000000000000 --- a/files/zh-cn/web/exslt/regexp/match/index.html +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: match -slug: Web/EXSLT/regexp/match -translation_of: Web/EXSLT/regexp/match ---- -

{{ XsltRef() }}

- -


- regexp:match() performs regular expression matching on a string, returning the submatches found as a result.

- -

语法

- -
regexp:match(targetString,regExpString[[,flagsString]])
-
- -

参数

- -
-
targetString
-
The string to perform regular expression matching upon.
-
regExpString
-
The JavaScript style regular expression to evaluate.
-
flagsString
-
An optional string containing character flags.
-
- -

The character flags are:

- -
-
g
-
全局匹配
-
The submatches from every match in the string are returned. If this flag isn't specified, only the submatches from the first match are returned.
-
i
-
Case insensitive match
-
If this flag is specified, the match is performed in a case insensitive fashion.
-
- -

Returns

- -

A node set of match elements, each of which has the string value equal to a portion of the first parameter string as captured by the regular expression. If the match isn't a global one, the first match element has the value of the portion of the string matched by the entire regular expression.

- -

例如:

- -
<xsl:for-each select="regExp:match('http://developer.mozilla.org/en/docs/Firefox_3_for_developers',
-                                   '(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)')">
-   Part <xsl:value-of select="position()" /> = <xsl:value-of select="." />
-</xsl:for-each>
-
- -

This code generates the following output:

- -
Part 1 = http://developer.mozilla.org/en/docs/Firefox_3_for_developers
-Part 2 = http
-Part 3 = developer.mozilla.org
-Part 4 =
-Part 5 = /en/docs/Firefox_3_for_developers
-
- -

定义

- -

EXSLT - REGEXP:MATCH

- -

Gecko support

- -

Supported in Gecko 1.9 and later.

diff --git a/files/zh-cn/web/exslt/regexp/match/index.md b/files/zh-cn/web/exslt/regexp/match/index.md new file mode 100644 index 00000000000000..985f4e7f6045c4 --- /dev/null +++ b/files/zh-cn/web/exslt/regexp/match/index.md @@ -0,0 +1,61 @@ +--- +title: match +slug: Web/EXSLT/regexp/match +translation_of: Web/EXSLT/regexp/match +--- +{{ XsltRef() }} + +`regexp:match()` performs regular expression matching on a string, returning the submatches found as a result. + +### 语法 + +```js +regexp:match(targetString,regExpString[[,flagsString]]) +``` + +### 参数 + +- `targetString` + - : The string to perform regular expression matching upon. +- `regExpString` + - : The JavaScript style regular expression to evaluate. +- `flagsString` + - : An optional string containing character flags. + +The character flags are: + +- `g` + - : 全局匹配。The submatches from every match in the string are returned. If this flag isn't specified, only the submatches from the first match are returned. +- `i` + - : Case insensitive match. If this flag is specified, the match is performed in a case insensitive fashion. + +### Returns + +A node set of `match` elements, each of which has the string value equal to a portion of the first parameter string as captured by the regular expression. If the match isn't a global one, the first match element has the value of the portion of the string matched by the entire regular expression. + +例如: + +```xml + + Part = + +``` + +This code generates the following output: + +```plain +Part 1 = http://developer.mozilla.org/en/docs/Firefox_3_for_developers +Part 2 = http +Part 3 = developer.mozilla.org +Part 4 = +Part 5 = /en/docs/Firefox_3_for_developers +``` + +### 定义 + +[EXSLT - REGEXP:MATCH](http://www.exslt.org/regexp/functions/match/index.html) + +### Gecko support + +Supported in Gecko 1.9 and later.