HTML DOM Event Object(转)

HTML DOM Event Object


Event Object

The event object gives you information about an event that has occurred.

The Event object represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.

Events are normally used in combination with functions, and the function will not be executed before the event occurs!


Event Handlers

New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of the attributes that can be inserted into HTML tags to define event actions.

IE: Internet Explorer, F: Firefox, O: Opera, W3C: W3C Standard.

AttributeThe event occurs when...IEFOW3C
onblurAn element loses focus319Yes
onchangeThe content of a field changes319Yes
onclickMouse clicks an object319Yes
ondblclickMouse double-clicks an object419Yes
onerrorAn error occurs when loading a document or an image419Yes
onfocusAn element gets focus319Yes
onkeydownA keyboard key is pressed31NoYes
onkeypressA keyboard key is pressed or held down319Yes
onkeyupA keyboard key is released319Yes
onmousedownA mouse button is pressed419Yes
onmousemoveThe mouse is moved319Yes
onmouseoutThe mouse is moved off an element419Yes
onmouseoverThe mouse is moved over an element319Yes
onmouseupA mouse button is released419Yes
onresizeA window or frame is resized419Yes
onselectText is selected319Yes
onunloadThe user exits the page319Yes

Mouse / Keyboard Attributes

PropertyDescriptionIEFOW3C
altKeyReturns whether or not the "ALT" key was pressed when an event was triggered619Yes
buttonReturns which mouse button was clicked when an event was triggered619Yes
clientXReturns the horizontal coordinate of the mouse pointer when an event was triggered619Yes
clientYReturns the vertical coordinate of the mouse pointer when an event was triggered619Yes
ctrlKeyReturns whether or not the "CTRL" key was pressed when an event was triggered619Yes
metaKeyReturns whether or not the "meta" key was pressed when an event was triggered619Yes
relatedTargetReturns the element related to the element that triggered the eventNo19Yes
screenXReturns the horizontal coordinate of the mouse pointer when an event was triggered619Yes
screenYReturns the vertical coordinate of the mouse pointer when an event was triggered619Yes
shiftKeyReturns whether or not the "SHIFT" key was pressed when an event was triggered619Yes

Other Event Attributes

PropertyDescriptionIEFOW3C
bubblesReturns a Boolean value that indicates whether or not an event is a bubbling eventNo19Yes
cancelableReturns a Boolean value that indicates whether or not an event can have its default action preventedNo19Yes
currentTargetReturns the element whose event listeners triggered the eventNo19Yes
eventPhaseReturns which phase of the event flow is currently being evaluated   Yes
targetReturns the element that triggered the eventNo19Yes
timeStampReturns the time stamp, in milliseconds, from the epoch (system start or event trigger)No19Yes
typeReturns the name of the event619Yes

转载于:https://www.cnblogs.com/timoli/archive/2010/09/10/1823148.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值