Mega Code Archive

 
Categories / JavaScript Tutorial / Window
 

Window captureEvents()

Syntax window.captureEvents(event)     window.captureEvents(event1 | event2 | eventN) The captureEvents() method captures all the events of the event type passed. If you have multiple events to capture, separate them with the pipe, |, character. The types of events that can be captured are as follows: Event.ABORT Event.BLUR Event.CHANGE Event.CLICK Event.DBLCLICK Event.DRAGDROP Event.ERROR Event.FOCUS Event.KEYDOWN Event.KEYPRESS Event.KEYUP Event.LOAD Event.MOUSEDOWN Event.MOUSEMOVE Event.MOUSEOUT Event.MOUSEOVER Event.MOUSEUP Event.MOVE Event.RESET Event.RESIZE Event.SELECT Event.SUBMIT Event.UNLOAD After an event has been captured, you can define a function to replace the built-in method for handling the event. <html>     <head>     <title>Using window.captureEvents</title>     <script language="JavaScript1.2">     <!--     var counter = 0;     window.captureEvents(Event.CLICK)     window.onclick = myClickHandler;          function myClickHandler(){       window.document.myForm.myText.handleEvent;     }          function changeText(){       document.myForm.myText.value = counter++;     }     -->     </script>     </head>     <body>     <form name="myForm">       <input type=TEXT size=2 value="" name="myText" onClick='changeText()'>     </form>     </body>     </html>