Share via


DHTML Events

Clicking a button, moving the mouse pointer over part of the Web page, selecting some text on the page — these actions all fire events, and a DHTML author can write code to run in response to the event. This particular piece of code is generally known as an event handler. The Internet Explorer event model makes it possible for every HTML element on the page to be the source for a full set of mouse and keyboard events.

The following tables show a set of common events that every HTML element generates in Internet Explorer.

Mouse events

Mouse event generated User action
onmouseover Moves the mouse pointer over (enters) an element.
onmouseout Moves the mouse pointer away from (exits) an element.
onmousedown Presses any of the mouse buttons.
onmouseup Releases any of the mouse buttons.
onmousemove Moves the mouse pointer within an element.
onclick Clicks the left mouse button on an element.
ondblclick Double-clicks the left mouse button on an element.

Keyboard events

Keyboard event generated User action
onkeypress Presses and releases a key (full down-and-up cycle). However, if a key is held down, multiple onkeypress events are fired.
onkeydown Presses a key. Only a single event is fired, even if the key is held down.
onkeyup Releases a key.

For more information about event handling in Internet Explorer, including event bubbling and handling rollover effects, see this Microsoft Web site.

See Also

Internet Explorer MSHTML/DHTML API

 Last updated on Friday, April 09, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.