<html> <body id="id"> body <script> window.onclick=function(e){ *!*var elem = e ? e.target : window.event.srcElement*/!*; alert(elem.id) } </script> </body> </html>