JavaScript Reference/Javascript Methods/setCapture

Материал из Web эксперт
Перейти к: навигация, поиск

"setCapture()" Example

    
<html>
<body>
<script language="JavaScript">
function function3() {
   myX.innerHTML = window.event.offsetX;
   myY.innerHTML = window.event.offsetY; 
} 
function function1() {
   myDiv.setCapture();
}
function function2() {
   myDiv.releaseCapture();
}
</script>
<p>
    <b>X Coordinate:</b> 
    <span id="myX">0</span>
</p>
<p>
    <b>Y Coordinate:</b> 
    <span id="myY">0</span>
</p>
<div id="myDiv" 
     onmousemove="function3();" 
     onclick="function2();" 
     style="border:solid; width:500;height:200;">
     Click inside the box to disable mouse capture outside the box
</div>
<button onclick="function1()">Set capture</button>
</body>
</html>



"setCapture()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <address>                     |
|                |<applet>                        <area>                        |
|                |<b>                             <big>                         |
|                |<blockquote>                    <body>                        |
|                |<br>                            <button>                      |
|                |<caption>                       <center>                      |
|                |<cite>                          <code>                        |
|                |<custom>                        <dd>                          |
|                |<dfn>                           <dir>                         |
|                |<div>                           <dl>                          |
|                |<dt>                            <em>                          |
|                |<embed>                         <fieldset>                    |
|                |<font>                          <form>                        |
|                |<hn>                            <hr>                          |
|                |<i>                             <img>                         |
|                |<input type="button">           <input type="checkbox">       |
|                |<input type="file">             <input type="hidden">         |
|                |<input type="image">            <input type="password">       |
|                |<input type="radio">            <input type="reset">          |
|                |<input type="submit">           <input type="text">           |
|                |<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>                                                         |
+----------------+--------------------------------------------------------------+



"setCapture()" Syntax, Parameters and Note

Note:
Turns mouse capture on for the specified element. 
When mouse capture is set to an element, that element will fire all 
mouse-related events.
    
Syntax:
    
document.all.elementID.setCapture(param1)
Parameters:
    param1   Optional; true or false, indicating whether or not the mouse 
                       capture affects the element"s parent.