UIEvent

UIEvent interface represents simple user interface events.

UIEvent derives from Event . Although the UIEvent.initUIEvent() method is kept for backward compatibility, you should create a UIEvent object using the UIEvent() 构造函数。

Several interfaces are direct or indirect descendants of this one: MouseEvent , TouchEvent , FocusEvent , KeyboardEvent , WheelEvent , InputEvent ,和 CompositionEvent .

构造函数

UIEvent()
创建 UIEvent 对象。

特性

This interface also inherits properties of its parent, Event .

UIEvent.cancelBubble
Boolean indicating whether the bubbling of the event has been canceled or not.
UIEvent.detail 只读
返回 long with details about the event, depending on the event type.
UIEvent.isChar 只读
返回 Boolean indicating whether the event produced a key character or not.
UIEvent.layerX 只读
Returns the horizontal coordinate of the event relative to the current layer.
UIEvent.layerY 只读
Returns the vertical coordinate of the event relative to the current layer.
UIEvent.pageX 只读
Returns the horizontal coordinate of the event relative to the whole document.
UIEvent.pageY 只读
Returns the vertical coordinate of the event relative to the whole document.
UIEvent.sourceCapabilities 只读
Returns an instance of the InputDeviceCapabilities interface, which provides information about the physical device responsible for generating a touch event.
UIEvent.view 只读
返回 WindowProxy that contains the view that generated the event.
UIEvent.which 只读
Returns the numeric keyCode of the key pressed, or the character code ( charCode ) for an alphanumeric key pressed.

方法

This interface also inherits methods of its parent, Event .

UIEvent.initUIEvent()
Initializes a UIEvent object. If the event has already being dispatched, this method does nothing.

规范

规范 状态 Comment
InputDeviceCapabilities 草案 添加 sourceCapabilities 特性。
UI Events 工作草案 Extend DOM3
Document Object Model (DOM) Level 3 Events Specification
The definition of 'UIEvent' in that specification.
Obsolete 添加 UIEvent() constructor, deprecated the initUIEvent() method and changed the type of view from AbstractView to WindowProxy .
Document Object Model (DOM) Level 2 Events Specification
The definition of 'UIEvent' in that specification.
Obsolete 初始定义

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
UIEvent Chrome Yes Edge 12 Firefox Yes IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
UIEvent() 构造函数 Chrome Yes Edge ≤18 Firefox 11 IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android 14 Opera Android Yes Safari iOS ? Samsung Internet Android Yes
cancelBubble
弃用 非标
Chrome Yes Edge 12 Firefox Yes IE Yes Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
detail Chrome Yes Edge 12 Firefox Yes IE 部分支持 9
部分支持 9
Always 0 on click and dblclick events. On mousedown and mouseup events, the count is not unique to the element, but is rather the global click count for the current document -- even across refreshes.
Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
initUIEvent
弃用 非标
Chrome Yes Edge 12 Firefox Yes IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS ? Samsung Internet Android Yes
isChar
弃用 非标
Chrome No Edge No Firefox ? — 55
不支持 ? — 55
isChar property has never been supported by any browser but Firefox, and even on Firefox it's never worked except on Mac OSX. For that reason, it's been removed in Firefox 55 to align with other browsers.
IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android ? — 55
不支持 ? — 55
isChar property has never been supported by any browser but Firefox, and even on Firefox it's never worked except on Mac OSX. For that reason, it's been removed in Firefox 55 to align with other browsers.
Opera Android No Safari iOS No Samsung Internet Android No
layerX
非标
Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
layerY
非标
Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
pageX
弃用 非标
Chrome ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageX in version 45.
Edge 12 Firefox ? IE 9 Opera ? Safari ? WebView Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageX in version 45.
Chrome Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageX in version 45.
Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ? — 4.0
不支持 ? — 4.0
Replaced by MouseEvent.pageX in Samsung Internet 5.0.
pageY
弃用 非标
Chrome ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Edge 12 Firefox ? IE 9 Opera ? Safari ? WebView Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Chrome Android ? — 44
不支持 ? — 44
Replaced by MouseEvent.pageY in version 45.
Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ? — 4.0
不支持 ? — 4.0
Replaced by MouseEvent.pageY in Samsung Internet 5.0.
sourceCapabilities
Chrome 47 Edge ≤79 Firefox ? IE ? Opera Yes Safari ? WebView Android 47 Chrome Android 47 Firefox Android ? Opera Android Yes Safari iOS ? Samsung Internet Android 5.0
view Chrome Yes Edge 12 Firefox Yes IE 9 Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes
which Chrome Yes Edge ≤79 Firefox Yes IE ? Opera Yes Safari Yes WebView Android Yes Chrome Android Yes Firefox Android Yes Opera Android Yes Safari iOS Yes Samsung Internet Android Yes

图例

完整支持
完整支持
部分支持
部分支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。

另请参阅