Add event handler listener to document : Event « Document « JavaScript DHTML






Add event handler listener to document

  

<html> 

<head> 
<title>W3C DOM Event Propagation</title> 
<script type="text/javascript"> 
function init() { 

    document.addEventListener("click", docEvent, true); 
} 

function docEvent(evt) { 
    alert("Document level."); 
} 

</script> 
</head> 
<body onload="init()"> 
</body> 
</html> 

   
    
  








Related examples in the same category

1.Set Capture
2.Release Capture
3.Detach Event
4.Attach an Event to element
5.Fire an Event