HTML and CSS Reference
In-Depth Information
EXAMPLE
13.21 (
CONTINUED
)
</form>
</body>
</html>
EXPLANATION
1
The HTML form starts here.
2
When the user clicks the first button in this form, the
onClick
event is triggered.
It will cause an alert message to appear displaying two event properties: the
type
of the event and the HTML element where it came from (
srcElement
(Internet Ex-
plorer) property of the object). The type of event is cross-browser compliant.
3
The input type for this form is a button. When the user clicks the button for In-
ternet Explorer, an alert box displays the type of the event and the source or object
from when it originated.
4
When the
onClick
event is triggered, an alert message will appear displaying two
event properties: the
type
of the event and the
target
(Firefox) property or object
from which the event originated. See Figures 13.30, 13.31, and 13.32. W3C and
Firefox both use the
target
property. Internet Explorer uses
srcElement
.
Figure 13.30
Displaying the event object's property in Internet Explorer (left), and
Firefox (right).
Figure 13.31
The user clicked the Firefox button.