Document Object Properties and Methods
Document Object Properties and Methods
The HTML5 DOM has methods, properties, and events for the <audio> and <video> elements. These methods,
properties, and events allow you to manipulate <audio> and <video> elements using JavaScript.
onafterprint after the document is printed onclick a mouse click on the element
onbeforeprint before the document is printed ondblclick a mouse double-click on the element
onchange the value of the element is changed oncanplay a file is ready to start playing
oncontextmenu a context menu is triggered oncanplaythrough a file can be played without pausing for buffering
onfocus the element gets focus ondurationchange the length of the media changes
onforminput a form gets user input onended the media has reach the end
oninput an element gets user input onerror an error occurs when the file is being loaded
onreset Reset button in a form is clicked onloadedmetadata meta data (like dimensions and duration) are loaded
Not supported in HTML5
onloadstart the file begins to load
onselect some text has been selected in an
element onpause the media is paused
MouseEvent/KeyboardEvent Object
Property Description
altKey Returns whether or not the "ALT" key was pressed when an event was triggered
button Returns which mouse button was clicked when an event was triggered
clientX Returns the horizontal coordinate of the mouse pointer, relative to the current window, when an event was triggered
clientY Returns the vertical coordinate of the mouse pointer, relative to the current window, when an event was triggered
ctrlKey Returns whether or not the "CTRL" key was pressed when an event was triggered
metaKey Returns whether or not the "meta" key was pressed when an event was triggered
relatedTarget Returns the element related to the element that triggered the event
screenX Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was triggered
screenY Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was triggered
shiftKey Returns whether or not the "SHIFT" key was pressed when an event was triggered
Event Object
Constant Description
AT_TARGET The current event is in the target phase, i.e. it is being evaluated at the event target (1)
cancelable Returns whether or not an event can have its default action prevented
currentTarget Returns the element whose event listeners triggered the event
eventPhase Returns which phase of the event flow is currently being evaluated
timeStamp Returns the time (in milliseconds relative to the epoch) at which the event was created
Method Description
initEvent() Specifies the event type, whether or not the event can bubble, whether or not the event's default action can be prevented
preventDefault() To cancel the event if it is cancelable, meaning that any default action normally taken by the implementation as a result of
the event will not occur
EventTarget Object
addEventListener() Allows the registration of event listeners on the event target (IE8 = attachEvent())
dispatchEvent() Allows to send the event to the subscribed event listeners (IE8 = fireEvent())
removeEventListener() Allows the removal of event listeners on the event target (IE8 = detachEvent())
EventListener Object
Method Description
handleEvent() Called whenever an event occurs of the event type for which the EventListener interface was registered
DocumentEvent Object
Method Description
createEvent()