Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Mouse Events

These events are the events triggered in response to mouse movements or mouse button presses. A few of these are familiar events, having been part of the Document Object Model before; some are new as a result of Dynamic HTML.

  onclick—This event is normally triggered when the user presses and releases the left mouse button. It can also occur when the user presses certain keys, such as Enter and Esc, in an HTML form.
A JavaScript onclick event handler is shown later. This event handler is triggered when a mouse click is recorded anywhere in the current document, and it uses the event object to pop up an Alert box to give the name of the HTML tag in which the click occurred.
<SCRIPT FOR=document EVENT=onclick LANGUAGE=“JAVASCRIPT”>
   alert(“Clicked in ” + window.event.srcElement.tagName);
</SCRIPT>
  ondblclick—This event is triggered when the user clicks twice over an object. If an event handler assigned to this event returns a false value, it cancels the default action.
  ondragstart—This event is triggered when the user begins a drag selection.
  onmousedown—This event is triggered when the user presses the mouse button.
  onmousemove—This event is triggered when the mouse is moved.
  onmouseover—This event is triggered when the mouse is moved into an object. It occurs when the mouse first enters the object and does not repeat unless the user moves the mouse out and then back in.
  onmouseout—This event is triggered when the user moves the mouse out of a given element. When the user moves the mouse pointer into an element, one onmouseover event occurs, followed by one or more onmousemove events as the user moves the pointer within the element; and finally, one onmouseout event occurs when the user moves the pointer out of the element.
  onmouseup—This event is triggered when the mouse button is released.

Note that some of the events described in the preceding list actually trigger multiple events. The events leading to a valid ondblclick event, for example, occur in the following steps:

1.  onmousedown
2.  onmouseup
3.  onclick
4.  onmousedown
5.  onmouseup
6.  ondblclick

Keystroke Events

New to Microsoft Internet Explorer with its support for Dynamic HTML are events triggered by user keypresses. Three general purpose events and one special purpose event respond to keys:

  onkeydown—This event is triggered when the user presses a key and returns the number of the keycode for the key pressed. An event handler assigned to service this event can return a different value and override the original key.
  onkeyup—Triggered when the user releases a key.
  onkeypress—The last event triggered for a valid key press: First the onkeydown event is triggered, and then onkeyup, and then onkeypress. Event handlers assigned to any of these three events can be used to intercept, override, and/or nullify the actual key pressed.
  onhelp—This event is triggered when the user presses the F1 key or clicks the Help key on the Web browser.

Focus Events

These events are used to follow the focus of the cursor around the HTML document. They can be used to good effect when performing HTML form validation but can also be used with non-form elements.

  onfocus—This event is triggered when the element in question receives the input focus.
  onblur—This event is triggered when an object loses the input focus.
  onchange—This event is triggered when the contents of the object, normally a text or text area HTML form field, are changed.
Note that this event is triggered only after the object has lost focus and if its contents have changed. If an event handler exists for the onblur event for the same object, the onchange event is triggered and executed first.

<MARQUEE> Events

Although Microsoft’s <MARQUEE> tag is a nonstandard HTML element, it has come into increasing use. Microsoft’s Dynamic HTML implementation includes three events specifically tied to that tag:

  onbounce—This event can only be triggered when the contents of the <MARQUEE> tag are set to alternately scroll one way and then the other. It is actually triggered when the scrolling content changes direction.
  onstart—This event is triggered when a scrolling loop begins or, for alternate behavior, when a bounce cycle begins.
  onfinish—This event is triggered when a scrolling loop ends.

Page Events

In addition to the onload event, which has existed in the past and is triggered when a Web page is completely loaded, Dynamic HTML adds a couple of other events associated with loading and unloading documents into your Web browser. This enables you to set the entrance and exit behaviors of the Web browser for a given document.

  onload—This event is triggered after the Web browser loads the given object. It is normally used with the HTML document itself, but can also be applied to images, applets, and any other Web browser object loaded along with the HTML document itself.
  onbeforeunload—This event is triggered prior to an HTML document being unloaded. By attaching an event handler to this event, you can give the user a chance to change his or her mind and remain on the current page.
  onunload—This event is triggered immediately before the current page is unloaded. Unlike the onbeforeunload event, after this event is triggered it is too late to prevent the user from leaving the page.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.