mousewheel | onmousewheel event

Fires when the wheel button is rotated.

Syntax

HTML Attribute <element onmousewheel = "handler(event)">
Event Property object.onmousewheel = handler;
attachEvent Method object.attachEvent("onmousewheel", handler)
addEventListener Method object.addEventListener("mousewheel", handler, useCapture)

 

Event information

SynchronousNo
BubblesYes
CancelableYes

 

Event handler parameters

pEvtObj [in]

Type: IHTMLEventObj

Standards information

There are no standards that apply here.

Remarks

The onmousewheel event is the only event that exposes the wheelDelta property. This property indicates the distance that the wheel button has rotated, expressed in multiples of 120. A positive value indicates that the wheel button has rotated away from the user. A negative value indicates that the wheel button has rotated toward the user. See the example below.

onmousewheel was introduced in Microsoft Internet Explorer 6

Scrolls the page up or down.

To invoke this event, do one of the following:

  • Rotate the wheel button.

Examples

The following example shows how to use the onmousewheel event and the wheelDelta parameter to expand and contract a picture in response to the wheel button being moved.

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


<html>
<head>
<script type="text/javascript">
var count = 10;
function Picture()
{
    if (event.wheelDelta >= 120)
        Resize(++count);
    else if (event.wheelDelta <= -120)
        Resize(--count);   
    return false;
}
function Resize(c){    
    oImage.style.zoom = c + '0%';
}
</script>
</head>
<body>
<img id="oImage" src="Sample.png" alt="sample "onmousewheel="Picture()">
</body>
</html>

See also

a
abbr
acronym
address
applet
area
audio
b
bdo
big
blockQuote
body
button
canvas
caption
center
cite
code
custom
dd
del
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=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
ins
kbd
label
legend
li
listing
map
marquee
menu
noBR
object
ol
p
plainText
pre
q
rt
ruby
s
samp
select
small
source
span
strike
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
tt
u
ul
var
video
window
xmp
Reference
onscroll
onmousemove
onmousedown
onmouseout
onmouseover
onmouseup

 

 

Show:
© 2014 Microsoft