Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title></title>
<script type="text/javascript">
function whichElement(e){
var targ;
if (!e){
var e=window.event;
}
if (e.target){
targ=e.target;
}else if (e.srcElement){
targ=e.srcElement;
}
if (targ.nodeType==3) { // defeat Safari bug
targ = targ.parentNode;
}
var tname;
tname=targ.tagName;
alert("You clicked on a " + tname + " element.");
}
</script>
</head>
<body onmousedown="whichElement(event)">
<p>Click somewhere in the document. An alert box will alert the tag name of the element you clicked on.</p>
<h3>This is a header</h3>
<p>This is a paragraph</p>
<img src="ball.gif" alt="Ball" />
</body>
</html>
Modify to suit.