HTML and CSS Reference
In-Depth Information
Event Attributes
To make Web pages more dynamic, HTML supports event attributes that identify scripts
to be run in response to an event occurring within an element. For example, clicking a
main heading with a mouse can cause a browser to run a program that hides or expands
a table of contents. Each event attribute has the form
on event = script
where event is the name of the event attribute and script is the name of the script or
command to be run by the browser in response to the occurrence of the event within
the element.
Core Events
The general event attributes are part of the specifi cations for HTML. They apply to almost
all page elements.
Attribute
Description
onabort
Loading of the element is aborted by the user (HTML5)
onclick
The mouse button is clicked.
oncontextmenu
The user requested the context menu for the element (HTML5)
ondblclick
The mouse button is double-clicked.
onerror
The element failed to load properly (HTML5)
onkeydown
A key is pressed down.
onkeypress
A key is initially pressed.
onkeyup
A key is released.
onload
The element finishes loading (HTML5)
onmousedown
The mouse button is pressed down.
onmousemove
The mouse pointer is moved within the element's boundaries.
onmouseout
The mouse pointer is moved out of the element's boundaries.
onmouseover
The mouse pointer hovers over the element.
onmouseup
The mouse button is released.
onmousewheel
The user rotates the mouse wheel
onreadystatechange
The element and its resources finish loading (HTML5)
onscroll
The element or document window is being scrolled (HTML5)
onshow
The user requests that the element be shown as a context menu (HTML5)
onsuspend
The browser suspends retrieving data (HTML5)
Document Events
The following list of event attributes applies not to individual elements within the page,
but to the entire document as it is displayed within the browser window or frame.
Attribute
Description
onafterprint
The document has finished printing (IE only).
onbeforeprint
The document is about to be printed (IE only).
onload
The page is finished being loaded.
onunload
The page is finished unloading.
 
Search WWH ::




Custom Search