View Full Version : help needed for clickhandler function

11-15-2012, 01:45 PM
The clickHandler function was supposed to display the name of the node or element on which the user clicked. By attaching the function to the body element the whole page was "clickable".

function clickHandler(e) {
var obj = e.XXXXX;
return false;
<body onload="return XXXXXXX (event);">

Can you please tell me what replaces the XXXXXX?

thx guys im strugglin a bit

11-15-2012, 08:50 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
function whichElement(e){
var targ;
if (!e){
var e=window.event;
if (e.target){
}else if (e.srcElement){
if (targ.nodeType==3) { // defeat Safari bug
targ = targ.parentNode;
var tname;
alert("You clicked on a " + tname + " element.");
<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" />

Modify to suit.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum