HTML and CSS Reference
In-Depth Information
EXPLANATION
1
This function will be called when a series of events are fired.
2
The attachEvent() method (IE) causes the onload event to fire when the page has
loaded. The onload event is a window event, and the function defined on line 1,
called greetings() will be called when that event is fired. This method requires that
you use the on prefix with the event handler (see Figure 15.45).
3
The attachEvent() method (IE) causes the click event to fire when the user clicks
anywhere on the document (i.e., Web page). When that happens the greetings()
function will be called.
4
The attachEvent() method (IE) causes a mouseover event to fire when the user
moves the mouse in the document. Two different events are tied to the document.
5
The detachEvent() method (IE) causes the mouse event created on line 4 to be re-
moved.
Figure 15.45 When the page loads an event is fired and when the user clicks
anywhere on the document another event is fired.
15.9.5 Event Properties Revisited
In Chapter 13 we discussed the event object. There are a number of event types defined
by the DOM HTML Events module, as shown in Table 15.8.
In Example 15.24, event listeners for both the DOM and Internet Explorer model are
listening for mouseOver and mouseOut events. The function parameter of the event lis-
teners change the style of a block of text to give it emphasis. When the mouse rolls over
a specific block of text, the event handler invokes a function that can check to see what
block of text the mouse is on and detect when it leaves the box. The node where the
 
 
Search WWH ::




Custom Search