HTML DOM event object
HTML DOM event
HTML DOM event allows Javascript register different event handlers in an HTML document element.
Events often used in conjunction with the function, the function will not be executed before the event occurs! (Such as the user clicks the button).
Tip: standardized event model in W3C Level 2 DOM event.
HTML DOM event
DOM: DOM attribute indicates the level of use.
Mouse events
Attributes | description | DOM |
---|
onclick | Event called when a user clicks on an object handle. | 2 |
oncontextmenu | Triggered when the user clicks the right mouse button to open the context menu | |
ondblclick | Event called when the user double-clicks an object handle. | 2 |
onmousedown | Mouse button is pressed. | 2 |
onmouseenter | Fires when the mouse pointer moves to the elements. | 2 |
onmouseleave | When the mouse pointer moves out of the trigger element | 2 |
onmousemove | The mouse is moved. | 2 |
onmouseover | Mouse over an element. | 2 |
onmouseout | Mouse away from an element. | 2 |
onmouseup | The mouse button is released. | 2 |
Keyboard events
Frame / Object (Frame / Object) event
Form events
Clipboard events
Attributes | description | DOM |
---|
oncopy | The event is triggered when the user copies the element content | |
oncut | The event is triggered when the user shear element content | |
onpaste | The event is triggered when the user paste the element content | |
Print Event
Attributes | description | DOM |
---|
onafterprint | The trigger event has already started printing the page, or print the window is already closed | |
onbeforeprint | The event is triggered when the page is about to start printing | |
Drag event
event | description | DOM |
---|
ondrag | The event is triggered when the element is being dragged | |
ondragend | The event is triggered when the user drags the elements to complete | |
ondragenter | This event is triggered when the dragged element into the drop target | |
ondragleave | This event is triggered when the drag element to leave the drop target | |
ondragover | The event is triggered when the target is placed on the drag element | |
ondragstart | The event is triggered when the user starts dragging elements | |
ondrop | This event is triggered when the drag element is placed in the target area | |
Multimedia (Media) Event
event | description | DOM |
---|
onabort | Event video / audio (audio / video) to terminate trigger when loading. | |
oncanplay | When the event is triggered in the user can start playing video / audio (audio / video). | |
oncanplaythrough | Trigger event can play in normal video / audio (audio / video) and without pause and buffer. | |
ondurationchange | Event video / audio (audio / video) Duration trigger change. | |
onemptied | Trigger list is empty, the current player | |
onended | At the end of play in the event trigger video / audio (audio / video). | |
onerror | Event triggered when an error occurs during video / audio (audio / video) data is loaded. | |
onloadeddata | Event in the browser to load the video / audio (audio / video) Trigger current frame. | |
onloadedmetadata | Event metadata specified video / audio (audio / video) trigger after loading. | |
onloadstart | Event in the browser to start looking specified video / audio (audio / video) trigger. | |
onpause | Trigger event in the video / audio (audio / video) Pause. | |
onplay | Event triggered to start playing the video / audio (audio / video). | |
onplaying | Event video / audio (audio / video) Pause or after buffering is triggered when ready to start playing again. | |
onprogress | Event Trigger (audio / video) specified in the browser to download video / audio. | |
onratechange | Trigger change event when sending video / audio (audio / video) playback speed. | |
onseeked | In the event the user to reposition the video / audio (audio / video) playback position triggered. | |
onseeking | Fires when the user starts to reposition event video / audio (audio / video). | |
onstalled | Get Media event data in the browser, but the media data is not available when triggered. | |
onsuspend | Event triggered suspension of media data in the browser to read. | |
ontimeupdate | Event triggered when the current playback position to send change. | |
onvolumechange | Event triggered when the volume change. | |
onwaiting | Since the event is triggered when the video you want to play the next frame buffer is required. | |
Animation events
event | description | DOM |
---|
animationend | This event is triggered when the animation finishes playing CSS | |
animationiteration | This event is triggered when the CSS animations repeat | |
animationstart | This event is triggered when the animation starts playing CSS | |
Transition event
event | description | DOM |
---|
transitionend | The event is triggered after the CSS to complete the transition. | |
Other events
event | description | DOM |
---|
onmessage | When the event is triggered by or from an object (WebSocket, Web Worker, Event Source or sub-frame or parent window) receives the message | |
onmousewheel | Obsolete. Use onwheel event substitute | |
ononline | This event is triggered when the browser to work online. | |
onoffline | This event is triggered when the browser should start working offline. | |
onpopstate | This event is triggered when the browsing history (history objects) of the window changes. | |
onshow | The event when the <menu> element is displayed in the context menu trigger | |
onstorage | This event is triggered when Web Storage (HTML 5 Web store) update | |
ontoggle | The event is triggered when the user opens or closes <details> element | |
onwheel | This event is triggered when the mouse wheel to scroll up and down in element | |
Event objects
constant
静态变量 |
描述 |
DOM |
CAPTURING-PHASE |
当前事件阶段为捕获阶段(3) |
1 |
AT-TARGET |
当前事件是目标阶段,在评估目标事件(1) |
2 |
BUBBLING-PHASE |
当前的事件为冒泡阶段 (2) |
3 |
Attributes
Attributes | description | DOM |
---|
bubbles | Returns a Boolean value that indicates whether the event is a bubbling event type. | 2 |
cancelable | Returns a Boolean value that indicates whether the event can cancel the default action pro. | 2 |
currentTarget | Returns its event listeners triggered the event element. | 2 |
eventPhase | Returns the current stage of the event spread. | 2 |
target | Returns the element that triggered this event (the event target node). | 2 |
timeStamp | Returns the date and time of the event generated. | 2 |
type | Returns the name of the current event Event object represents. | 2 |
method
方法 |
描述 |
DOM |
initEvent() |
初始化新创建的 Event 对象的属性。 |
2 |
preventDefault() |
通知浏览器不要执行与事件关联的默认动作。 |
2 |
stopPropagation() |
不再派发事件。 |
2 |
Target event object
method
方法 |
描述 |
DOM |
addEventListener() |
允许在目标事件中注册监听事件(IE8
= attachEvent()) |
2 |
dispatchEvent() |
允许发送事件到监听器上 (IE8 =
fireEvent()) |
2 |
removeEventListener() |
运行一次注册在事件目标上的监听事件(IE8 =
detachEvent()) |
2 |
Object Event Listener
method
方法 |
描述 |
DOM |
handleEvent() |
把任意对象注册为事件处理程序 |
2 |
Document Object Event
method
方法 |
描述 |
DOM |
createEvent() |
|
2 |
Mouse / keyboard event object
Attributes
属性 |
描述 |
DOM |
altKey |
返回当事件被触发时,"ALT" 是否被按下。 |
2 |
button |
返回当事件被触发时,哪个鼠标按钮被点击。 |
2 |
clientX |
返回当事件被触发时,鼠标指针的水平坐标。 |
2 |
clientY |
返回当事件被触发时,鼠标指针的垂直坐标。 |
2 |
ctrlKey |
返回当事件被触发时,"CTRL" 键是否被按下。 |
2 |
Location |
返回按键在设备上的位置 |
3 |
charCode | 返回onkeypress事件触发键值的字母代码。 | 2 |
key | 在按下按键时返回按键的标识符。 | 3 |
keyCode | 返回onkeypress事件触发的键的值的字符代码,或者 onkeydown 或 onkeyup 事件的键的代码。 | 2 |
which | 返回onkeypress事件触发的键的值的字符代码,或者 onkeydown 或 onkeyup 事件的键的代码。 | 2 |
metaKey |
返回当事件被触发时,"meta" 键是否被按下。 |
2 |
relatedTarget |
返回与事件的目标节点相关的节点。 |
2 |
screenX |
返回当某个事件被触发时,鼠标指针的水平坐标。 |
2 |
screenY |
返回当某个事件被触发时,鼠标指针的垂直坐标。 |
2 |
shiftKey |
返回当事件被触发时,"SHIFT" 键是否被按下。 |
2 |
method
方法 |
描述 |
W3C |
initMouseEvent() |
初始化鼠标事件对象的值 |
2 |
initKeyboardEvent() |
初始化键盘事件对象的值 |
3 |