HTML and CSS Reference
In-Depth Information
EXAMPLE 13.9 ( CONTINUED )
10
<form>
<input type="button"
value="onMouseMove"
11
onMouseMove="track_Moves();" />
</form>
</p>
</body>
</html>
EXPLANATION
1
A JavaScript program starts here.
2
A global variable called counter is initialized.
3
If the user double-clicks the mouse anywhere on the page, an alert dialog box will
appear; if the user clicks OK in the alert dialog box, the window will be closed.
4
The window 's close method causes the current window to be closed.
5
This function is called when the onMouseOver event handler is triggered. This
event happens when the user touches the mouse on an object, in this case, a but-
ton object.
6
The counter is incremented by one every time the user touches the button.
7
The onDblClick event handler is an attribute of the HTML <body> tag. When the
user double-clicks the mouse, the alertme() function will be called, and the win-
dow closed.
8
The onMouseOver event handler is an attribute of the <a href> link tag. It is trig-
gered anytime the user moves the mouse over the link. (The link has been deac-
tivated by using the # sign.) When this event occurs, the alert method is called.
9
The onMouseOut event handler is an attribute of the <a href> link tag. Any time
the user moves the mouse away from this link, the event is triggered, and the alert
method is called.
10
The form starts here. The input type is a button.
11
When the user's mouse touches the button, the onMouseMove event handler is
triggered, and the track_Moves() function is called. This function will simply in-
crement a counter by one each time it is called, and then alert the user.
 
Search WWH ::




Custom Search