HTML and CSS Reference
In-Depth Information
Table 10-8 shows some of the event handlers and the associated objects. As the table
indicates, event handlers can be used only with certain objects. For example, the onClick
event handler is used to trigger JavaScript code when a user clicks a button or link, while
the onLoad event handler is used to trigger JavaScript code when a document is loaded
into the browser window. For more information about event handlers, see the JavaScript
Quick Reference in Appendix G.
Table 10-8 Objects and Associated Event Handlers
Object
Event Handler
onClick, onDblClick
button
onLoad, onUnload
document
onSubmit, onReset, onBlur, onKeydown, onKeypress, onKeyup
form
onClick, onMouseover, onMouseout, onDblClick, onMousemove,
onMousedown
hyperlink
image
onLoad, onAbort, onError, onMousemove, onMousedown
input box
onBlur, onChange, onFocus, onKeypress, onKeyup, onKeydown
Submit button
onClick
window
onLoad, onUnload, onBlur, onFocus
In this chapter, the onLoad event handler calls the scrollingMsg() function, using
the following statement:
onLoad=”scrollingMsg()”
where onLoad is the event handler and the scrollingMsg() function is the code that is
executed as the result of the event. The statement is entered in the <body> tag to indicate
that the onLoad event handler should call the scrollingMsg() function when the Web
page loads.
To Enter the onLoad Event Handler to Call the scrollingMsg() Function
The following step enters the onLoad event handler to call the scrollingMsg() function.
1
onLoad event handler to
call scrollingMsg() function
when page loads
the y in body in line 76.
Click to the right of
Press the
s p a c e b a r
once.
onLoad=
”scrollingMsg();”
to add the event
handler and do not
press the e n t e r key
(Figure 10-12).
Type
do not press
e n t e r key
Figure 10-12
 
Search WWH ::




Custom Search