Get your own website Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<head>
<script>
function whichElement(e) {
  var targ;
  if (!e) {
    var e = window.event;
  }
  if (e.target) {
    targ=e.target;
  } else if (e.srcElement) {
    targ=e.srcElement;
  }
  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 name of the element you clicked on.</p>
<h3>This is a heading</h3>
<img border="0" src="smiley.gif" alt="Smiley" width="32" height="32">
<p>This is a paragraph.</p>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_events_srcelement by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:07:12 GMT -->
</html>