Window.captureEvents()

这篇翻译不完整。请帮忙从英语翻译这篇文章

已废弃 Gecko 1.9 (Firefox 3)
该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

非标准
该特性是非标准的,请尽量不要在生产环境中使用它!

概要

注册窗口以捕获指定类型的所有事件。

Syntax

window.captureEvents(eventType) 

eventType is a combination of the following values: Event.ABORT, Event.BLUR, Event.CLICK, Event.CHANGE, Event.DBLCLICK, Event.DRAGDDROP, Event.ERROR, Event.FOCUS, Event.KEYDOWN, Event.KEYPRESS, Event.KEYUP, Event.LOAD, Event.MOUSEDOWN, Event.MOUSEMOVE, Event.MOUSEOUT, Event.MOUSEOVER, Event.MOUSEUP, Event.MOVE, Event.RESET, Event.RESIZE, Event.SELECT, Event.SUBMIT, Event.UNLOAD.

Example

<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<script>
function reg() {
  window.captureEvents(Event.CLICK);
  window.onclick = page_click;
}

function page_click() {
  alert('page click event detected!');
}
</script>
</head>

<body onload="reg();">
<p>click anywhere on this page.</p>
</body>
</html>

Notes

Events raised in the DOM by user activity (such as clicking buttons or shifting focus away from the current document) generally pass through the high-level window and document objects first before arriving at the object that initiated the event.

When you call the captureEvents() method on the window, events of the type you specify (for example, Event.CLICK) no longer pass through to "lower" objects in the hierarchy. In order for events to "bubble up" in the way that they normally do, you must call window.releaseEvents() ( ) on the window to keep it from trapping events.

Note that you can pass a list of events to this method using the following syntax: window.captureEvents(Event.KEYPRESS | Event.KEYDOWN | Event.KEYUP).

Specification

This is not part of any specification.

文档标签和贡献者

 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,