<html>
<head>
<title>Abakada DHTML Demo: onclick Event Handler Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="JavaScript">
<!--
function clickMe ( ) {
alert ( window.event.srcElement.tagName + " " + window.event.srcElement.type );
txtOutput.value = window.event.srcElement.tagName;
txtOutput1.value = window.event.srcElement.type;
/* This code determines whether the click occurred in an anchor,
and then cancels the event, preventing the jump. */
if ( window.event.srcElement.tagName == "A" ){
window.event.returnValue = false; }
}
//-->
</script>
</head>
<body onclick="clickMe ( )">
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>Abakada DHTML Demo: <span class="hilite">onclick Event Handler</span> Example</h2></div>
<hr size=1 width=92%>
<center>
<p>The <b>onclick</b> event occurs when the user clicks the left mouse button on an object. </p>
<p>This example uses the event to trigger a function that returns the event's <b>srcElement</b> <i>tagName</i> and <i>type</i>. </p>
<p>Click on each of the following objects and anywhere else on this document and see what has been clicked. </p>
<div align="center">
<p><input value="Click me" onclick="clickMe ( )">
<input type="button" value="Click me" onclick="clickMe ( )">
<a href="" onclick="clickMe ( )">Click me</a></p>
<p>What's been clicked: </p>
<p><input id="txtOutput" name="txtOutput"> <input id="txtOutput1" name="txtOutput1"></p>
</center>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>