<html>
<head>
<title>Using the type property for the event object</title>
</head>
<body>
<script language="Javascript">
<!--
function handle(evnt){
if(evnt.type == "click"){
document.form1.msg.value += "The click event occurred.\n"
}
if(evnt.type == "mousedown"){
document.form1.msg.value += "The mousedown event occurred.\n"
}
if(evnt.type == "keypress"){
document.form1.msg.value += "The keypress event occurred.\n"
}
return true;
}
document.onkeypress = handle;
document.onclick = handle;
document.onmousedown = handle;
-->
</script>
<form name="form1">
This page demonstrates a few different events.
Upon events occurring, a message will be displayed in the textarea indicating which event occurred.
<br><br><br>
<ul>
<li><input type="Button" value="Click Me"></li>
<br><br>
<li>
Dummy text area.
<input type="text" size="20">
<br>
Click mouse in text field.
<br><br>
</li>
<br><br>
<b>Message output:</b>
<textarea name="msg" rows="10" cols="60"></textarea>
<br><br>
<input type="reset" value="Clear">
</form>
</body>
</html>
|