HTML and CSS Reference
In-Depth Information
Figure 13.3 Using the onSubmit event and return values. If the return value is true
the form is submitted; otherwise, it is stopped.
tag, whereas an event method is applied to an object. Because HTML elements are also
treated as objects (e.g., the window, form, or button are also JavaScript objects), there
are several methods that can be applied to these objects to simulate events (see
Table 13.2). When an object uses an event method, the method behaves as though the
event has happened; for example, the click() method behaves like the onClick event, the
blur() method behaves like the onBlur event, and so on. 1 The event method is applied to
the object with the dot syntax, as are all other methods; for example, in a JavaScript pro-
gram you might see something like the following:
document.test.button1.click(), window.focus(),
document.myform.submit();
Table 13.2 Event Object Methods
Event
Method
Event Handler It
Simulates
The Object It Can Affect
blur()
onBlur
Removes focus from windows, frames, form fields.
click()
onClick
Simulates a mouse click in form fields (buttons).
focus()
onFocus
Puts focus in a window, frame, form field.
reset()
onReset
Clears the form fields.
select()
onSelect
Selects or highlights text in a form field.
submit()
onSubmit
Submits a form.
1. Event methods behave as though the event has happened but in themselves do not trigger an event
handler. For example, the click() method does not trigger the onClick event handler.
 
Search WWH ::




Custom Search