[HTML API]Event

 

[Constructor(DOMString type, optional EventInit eventInitDict)]
interface Event {
  readonly attribute DOMString type;
  readonly attribute EventTarget? target;
  readonly attribute EventTarget? currentTarget;

  const unsigned short CAPTURING_PHASE = 1;
  const unsigned short AT_TARGET = 2;
  const unsigned short BUBBLING_PHASE = 3;
  readonly attribute unsigned short eventPhase;

  void stopPropagation();
  void stopImmediatePropagation();

  readonly attribute boolean bubbles;
  readonly attribute boolean cancelable;
  void preventDefault();
  readonly attribute boolean defaultPrevented;

  readonly attribute boolean isTrusted;
  readonly attribute DOMTimeStamp timeStamp;

  void initEvent(DOMString type, boolean bubbles, boolean cancelable);
};

dictionary EventInit {
  boolean bubbles;
  boolean cancelable;
};

type

释义

type属性必须其预置的值。当创建一个事件时,该属性必须被预置为空字符串。

兼容性状态

IE 6 支持。
IE 7/8 支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

targetcurrentTarget

释义

target和currentTarget属性必须返回其预置的值。当创建一个事件时,该属性必须被预置为空(null)。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

CAPTURING_PHASEAT_TARGETBUBBLING_PHASE

释义

用于表示事件所处阶段的常量。

CAPTURING_PHASE
捕获阶段 - 1。若指派了一个事件到一个参加了树的对象,在其达到target属性的值之前,其处于此阶段。
AT_TARGET
到达目标 - 2。若指派了一个事件,在其到达其target属性的值时,其处于此阶段。
BUBBLING_PHASE
冒泡阶段 - 3。若指派了一个事件到一个参加了树的对象,在其达到target属性的值之后,其处于此阶段。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

eventPhase

释义

eventPhase属性必须返回其预置的值,其必须为上述常量之一,该属性必须首先被预置为AT_TARGET。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

stopPropagation()

释义

调用stopPropagation()方法时,必须设置停止扩展标记。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

stopImmediatePropagation()

释义

调用stopImmediatePropagation()方法时,必须设置停止扩展标记和立即停止扩展标记。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 不支持。
Safari  

bubblescancelable

释义

bubbles和cancelable属性必须返回它们各自预置的值。当创建一个事件时,这些属性必须被预置为假。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

preventDefault()

释义

调用preventDefault()方法时,如果cancelable属性为真,则必须设置撤销标记。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

defaultPrevented()

释义

如果设置了撤销标记,则defaultPrevented属性必须返回真,否则必须返回假。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

isTrusted

释义

isTrusted属性必须返回其预置的值。当创建一个事件时,该属性必须被预置为假。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 不支持。
Firefox 支持。
Safari  

timeStamp

释义

timeStamp属性必须返回其预置的值。当创建一个事件时,该属性必须被预置为从1970年1月1日UTC时区下00:00:00至今所经过的毫秒数。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  

initEvent(type, bubbles, cancelable)

释义

调用initEvent(type, bubbles, cancelable)方法时,必须:

  • 设置预置标记;
  • 删除停止扩展标记、立即停止扩展标记和撤销标记;
  • 设isTrusted属性为假;
  • 设target属性为空;
  • 设type属性为type参数;
  • 设bubbles属性为bubbles参数;
  • 设cancelable属性为cancelable参数。

兼容性状态

IE 6 不支持。
IE 7/8 不支持。
IE 9+  
Chrome 支持。
Firefox 支持。
Safari  
posted @ 2012-02-06 11:55  NiuWeb  阅读(337)  评论(0)    收藏  举报