Вы находитесь на странице: 1из 2

Event Object

Events are actions that can be detected by JavaScript, and the event object gives information about the event that has occurred. Sometimes we want to execute a JavaScript when an event occurs, such as when a user clicks a button. Events are normally used in combination with functions, and the function will not be executed before the event occurs!

Event Attributes
Below is the event attributes that can be inserted into different HTML elements to define event actions. IE: Internet Explorer, F: Firefox, O: Opera, W3C: W3C Standard. Attribute onblur onchange onclick ondblclick onerror onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseout onmouseover onmouseup onresize onselect onunload The event occurs when... An element loses focus The content of a field changes Mouse clicks an object Mouse double-clicks an object An error occurs when loading a document or an image An element gets focus A keyboard key is pressed A keyboard key is pressed or held down A keyboard key is released A page or image is finished loading A mouse button is pressed The mouse is moved The mouse is moved off an element The mouse is moved over an element A mouse button is released A window or frame is resized Text is selected The user exits the page IE 3 3 3 4 4 3 3 3 3 3 4 3 4 3 4 4 3 3 F 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 O 9 9 9 9 9 9 No 9 9 9 9 9 9 9 9 9 9 9 W3C Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

Mouse / Keyboard Attributes

Property altKey button clientX clientY ctrlKey metaKey relatedTarget screenX screenY shiftKey

Description Returns whether or not the "ALT" key was pressed when an event was triggered Returns which mouse button was clicked when an event was triggered Returns the horizontal coordinate of the mouse pointer when an event was triggered Returns the vertical coordinate of the mouse pointer when an event was triggered Returns whether or not the "CTRL" key was pressed when an event was triggered Returns whether or not the "meta" key was pressed when an event was triggered Returns the element related to the element that triggered the event Returns the horizontal coordinate of the mouse pointer when an event was triggered Returns the vertical coordinate of the mouse pointer when an event was triggered Returns whether or not the "SHIFT" key was pressed when an event was triggered

IE F O W3C 6 6 6 6 6 6 1 1 1 1 1 1 9 9 9 9 9 9 9 9 9 9 Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

No 1 6 6 6 1 1 1

Other Event Attributes


Property bubbles cancelable currentTarget eventPhase target timeStamp type Description Returns a Boolean value that indicates whether or not an event is a bubbling event Returns a Boolean value that indicates whether or not an event can have its default action prevented Returns the element whose event listeners triggered the event Returns which phase of the event flow is currently being evaluated Returns the element that triggered the event Returns the time stamp, in milliseconds, from the epoch (system start or event trigger) Returns the name of the event IE F O W3C No 1 No 1 No 1 9 9 9 Yes Yes Yes Yes No 1 No 1 6 1 9 9 9 Yes Yes Yes

Вам также может понравиться