Sets the mouse capture to the object that belongs to the current document.
- containerCapture [in, optional]
Specifies one of the following values.
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
There are no standards that apply here.
After mouse capture is set to an object, all mouse events for the document are routed to that object. Supported mouse events include onmousedown, onmouseup, onmousemove, onclick, ondblclick, onmouseover, and onmouseout. The srcElement property of the window event object always returns the object that is positioned under the mouse, instead of the object that has mouse capture.
When the containerCapture parameter is set to
true, a container object, such as a div, captures mouse events for all objects in it. By passing the value
false, objects in that container can fire events, and cancel event bubbling.
Drag-and-drop operations, such as the ondragstart event, and text selection through the user interface are disabled when mouse capture is set programmatically. The following key events are unaffected by mouse capture and fire as usual: onkeydown, onkeyup, and onkeypress.
Mouse clicks automatically trigger the onlosecapture event. To retain mouse capture, call setCapture inside the onclick event handler. Mouse capture is also lost if the browser window loses focus for any reason (including alerts or pop-up windows).
- input type=button
- input type=checkbox
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=url
- About Mouse Capture