|
May 17, 2000 Capturing Events at a High Level Tips: May 2000
Yehuda Shiran, Ph.D.
|
|
Netscape Navigator requires the captureEvents() method to capture events outside of its intended target (in the window, layer, or document object). For example, the following code segment captures all mouseup events in the document:
Since Internet Explorer's event model is based on event bubbling, an event is first directed to its intended target (the element that initiated the event). Therefore, the
On Internet Explorer 4.0x and older browsers (Navigator and Internet Explorer), only the second statement is executed. Therefore this script is also backward compatible. In other words, it does not generate an error on older browsers. It obviously doesn't work with such browsers, because they do not support the
When the user clicks the mouse button anywhere in the page's background, the script generates an alert dialog box provided that the user is running a fourth-generation browser, or higher. Learn more about event handlers in Column 10, The Internet Explorer Event Model.
People who read this tip also read these tips: Look for similar tips by subject: |