spacer
Yehuda Shiran July 14, 2000
The setCapture() Method
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Usually, an object fires an event when the event occurs within its physical limits on the page. For example, if you specify an onmousemove event for a DIV element, the appropriate event handler kicks in only when the mouse moves inside the DIV box.

Sometimes, though, you want an object to capture events that occur within other objects. You can do it with the setCapture() method:

object.setCapture([flag]);

where flag is an optional parameter equal to either false (no capturing), or true (default).

The following box is designed to capture onmousemove events from the whole document. You can turn this capturing off and on by a mouse click. Play around with the mouse and make sure the setCapture() method is working according to the specifications.

Supported mouse events include onmousedown, onmouseup, onmousemove, onclick, ondblclick, onmouseover, and onmouseout. The srcElement property of the window's event object always returns the object that is positioned under the mouse rather than the object that has mouse capture. The following key events are unaffected by mouse capture, and fire as usual: onkeydown, onkeyup, and onkeypress.

For more on the event model, go to Column 9, The Navigator Event Model, Column 10, The Internet Explorer Event Model, and Column 11, The Cross Browser Event Model.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint