EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

releaseCapture method

Removes mouse capture from the object in the current document.

Syntax

object.releaseCapture()

Parameters

This method has no parameters.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

There are no standards that apply here.

Remarks

For releaseCapture to have an effect, you must set mouse capture through the setCapture method.

You can invoke the releaseCapture method on the document object. The releaseCapture method makes it unnecessary to determine which element has capture to programmatically release it. Other actions that release document capture include displaying a modal dialog box and switching focus to another application or browser window.

Examples

This example invokes the releaseCapture method on the document object.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/releaseCaptureEX.htm


<!DOCTYPE html>
<html>
<head>
  <title>Example of the releaseCapture Method on an Object</title>
  <style>
    #divOwnCapture {
      height: 275px;
      width: 400px;
      background-color: gray;
      font-family: sans-serif;
      font-size: 12pt;
    }

    #divNoCapture {
      height: 275px;
      width: 400px;
      background-color: white;
      font-family: sans-serif;
      font-size: 12pt;
    }
  </style>
</head>

<body onload="divOwnCapture.setCapture();" onclick="document.releaseCapture();">
  <div id="divOwnCapture" onmousemove="txtWriteLocation.value = event.clientX + event.clientY;" onlosecapture="alert(event.srcElement.id + ' has lost mouse capture.')">
    <p>
      Mouse capture has been set to this gray division (<strong>DIV</strong>) at
      load time using the <strong>setCapture</strong> method. The text area will display
      mouse coordinates for the <strong>mousemove</strong> event anywhere in the document.
    </p>
    <textarea id="txtWriteLocation" cols="2"></textarea>
  </div>
  <div id="divNoCapture">
    <p>Click the document to invoke the <strong>releaseCapture</strong> method of the document object.</p>
  </div>
</body>
</html>

See also

a
address
applet
area
b
big
blockQuote
body
br
button
caption
center
cite
code
custom
dd
dfn
dir
div
dl
document
dt
em
embed
fieldSet
font
form
hn
hr
i
img
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
kbd
label
legend
li
listing
map
marquee
menu
noBR
object
ol
option
p
plainText
pre
s
samp
select
small
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
tt
u
ul
var
xmp
Reference
onlosecapture
setCapture
msSetPointerCapture
msReleasePointerCapture
Conceptual
About Mouse Capture

 

 

Afficher:
© 2014 Microsoft