Filed Under (Javascript Code Samples) by Anoop on May-22-2007
Code (javascript)

<script>
window.captureEvents(Event.CLICK);
window.onclick=sourceCheck;

function sourceCheck(e){
var el=(typeof event!=='undefined')? event.srcElement : e.target
alert(el.tagName)
}
</script>
 

Above code works fine in FireFox but not in IE.

Here is the one that works in Both:

Code (javascript)

<script type="text/javascript">
if (window.captureEvents){
window.captureEvents(Event.CLICK);
window.onclick=sourceCheck;
}
else
document.onclick=sourceCheck;

function sourceCheck(e){
var el=(typeof event!=='undefined')? event.srcElement : e.target
alert(el.tagName)
}
</script>
 


Pedro Silva on June 10th, 2007 at 5:49 am #

Nice code. Thanks.

memals on November 29th, 2007 at 9:56 pm #

the routeEvents has the same problem but I can not find a solution.
And once I have fixed that then there is releaseEvents

Post a comment
Name: 
Email: 
URL: 
Comments: