HTML and CSS Reference
In-Depth Information
Table G-9 Event Handlers (continued)
Event Handler
Triggered When
Handler For
Used in HTML Statement
onclick
An element is clicked
once
Button, Checkbox,
Document, Link, Radio,
Reset, Submit
<a> ... </a>
<input type 5 ”submit” />
<input type 5 ”reset” />
<input type 5 ”radio” />
<input type 5 ”checkbox” />
<input type 5 ”text” />
onclose
Current window is being
closed
Window elements
oncontextmenu
Right-click to fire context
menu
Return of false prevents
context menu from
displaying
All elements
oncopy
Text is being copied to be
placed on Clipboard
Return of false prevents
text from being copied
<textarea> ... </textarea>
<input type 5 ”text” />
<select> ... </select>
oncut
Text is being cut to be
placed on Clipboard
Return of false disables
cutting of text
<textarea> ... </textarea>
<input type 5 ”text” />
<select> ... </select>
ondblclick
An element is double-
clicked
Document, Link
<a> ... </a>
<input type 5 ”submit” />
<input type 5 ”reset” />
<input type 5 ”radio” />
<input type 5 ”checkbox” />
<input type 5 ”text” />
ondragdrop
An object is dragged and
dropped into a window
Window (may not be
available on all platforms)
<body> ... </body>
onerror
An error occurs when
loading a document or
image
Image, Window
<img />
<body> ... </body>
onfocus
An element becomes
active
Button, Checkbox,
FileUpload, Layer, Password,
Radio, Reset, Select,
Submit, Text, Textarea,
Window (may not be
available on all platforms)
<body> ... </body>
<input type 5 ”text” />
<textarea> ... </textarea>
<select> ... </select>
onhashchange
Fires when the hash
portion (anything
after the #) of a URL is
changed
Firefox 3.5 and Internet
Explorer 8+ only in Window
and Body elements
onkeydown
A designated key is
pressed
Document, Image, Link,
Textarea
<body> ... </body>
<img />
<a> ... </a>
<textarea> ... </textarea>
onkeypress
A designated key is
pressed and released
Document, Image, Link,
Textarea
<body> ... </body>
<img />
<a> ... </a>
<textarea> ... </textarea>
onkeyup
A designated key is
released
Document, Image, Link,
Textarea
<body> ... </body>
<img />
<a> ... </a>
<textarea> ... </textarea>
onload
A document or image
loads
Image, Layer, Window
<img />
<body> ... </body>
Search WWH ::




Custom Search