Click to See Complete Forum and Search --> : ok guys new prob


z_mirza
06-05-2003, 08:43 PM
i need to know how i can find out which object recived an event. i do know that there is an event object in the window object but im not sure how to use it. any help would be great, or an exmple would be great thanx

Khalid Ali
06-05-2003, 09:21 PM
for a general use on whole of the page,you can set the document to recieve click events

The code snippet below is tested(IE6+,NS6+ &opera7+).


function clickHandler(e){
var events = (document.all)?event:e;
//now you can get the event source
var esrc = (document.all)?event.srcElement:e.target;
alert(esrc.nodeName)
}

if(!document.all){//ns6+
document.captureEvents(Event.CLICK);
}
document.onclick=clickHandler;