您的位置:首页 > 移动开发 > Objective-C

HTML DOM Event Object(转)

2010-09-10 12:11 726 查看

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 evaluatedYes
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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: