Export (0) Print
Expand All

wheelDelta property

Retrieves the distance and direction the wheel button has rolled.

Syntax

JavaScript

p = object.wheelDelta

 

Property values

Type: Integer

the distance and direction that the wheel button has rolled.

Remarks

This property indicates the distance that the wheel has rotated, expressed in multiples of 120. A positive value indicates that the wheel has rotated away from the user. A negative value indicates that the wheel has rotated toward the user.

This property is used with the onmousewheel event.

wheelDelta was introduced in Microsoft Internet Explorer 6

Examples

The following example shows how to use the wheelDelta with the onmousewheel event to measure the distance the wheel button has rotated. Measurement values of wheelDelta are in multiples of 120.

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


<!DOCTYPE html>
<html>
<head>
  <title>wheelDelta Property Example</title>
  <style>
    .intro {
      background: #e4e4e4;
      color: black;
      font-weight: bold;
      font-size: 13pt;
      padding: 10px;
    }
  </style>
</head>

<body>
  <h1>wheelDelta Property Example</h1>
  <p>Roll the mousewheel back and forth to observe the value of <strong>wheelDelta</strong> property.</p>
  <div class="intro">
    wheelDelta: (<span style="color: red" id="oNotice"></span>)
  </div>
  <script>
    var oNotice = document.getElementById('oNotice');
    window.addEventListener('mousewheel', handleMouseWheel, false);
    function handleMouseWheel(evt) {
      oNotice.textContent = evt.wheelDelta;
    }
  </script>
</body>
</html>

See also

event

 

 

Show:
© 2014 Microsoft