Is the use of the mouse wheel a measurable event in Javascript or VBscript?

Is the use of the scrolly mouse wheel an event that's
capturable in Javascript... or VBscript?

Mine lets you scroll up and down the page, or if you click it
you can use the mouse itself to scroll.

Is that an event that's detectable somehow?
If so, can you give me an example of how that's done?

(BTW, is there a VBscript section on this site? I couldn't
find it anywhere!)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
The event object of IE 5.5 and above has a wheelDelta property that indicates the direction of the wheel roll. It is an integer with positive being toward the screen or up and negative away from the screen or down.

if (evt.type == "mousewheel" ) {

      if (window.event && window.event.wheelDelta ) {
           if (window.event.wheelDelta > 0) alert("Wheel rolled up");
           else if (window.event.wheelDelta < 0)alert("Wheel rolled down");
           else alert("Not up or Down");
sleepybearAuthor Commented:
Sorry ljo8877, but I'm not sure how to call your script example.

Can you place your code in a full html head and body page example
so I can see what you mean? Sorry, but I've just never seen this
done before so I don't know how to plug it in to anything.

I'm sure you can attach or bind a function to the onMouseWheel event in either of the three common ways -- addListener/attachEvent, document.onmousewheel = fxName;, or onmousewheel="fxName();" in a tag. I've chosen the later for this example as a matter of convenience. In this demo a text box will display the direction the mouse wheel is rolled when the mouse is in a dropdown listbox. (I dumped the alerts because they change the focus and you don't get to see the entries scroll.)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>demo capture of mousewheel</title>

<script type="text/javascript">
function getWheel(){
     if (window.event.type == "mousewheel" ) {
          if (window.event && window.event.wheelDelta ) {
                var msge = "";
                if (window.event.wheelDelta > 0) msge = "Wheel rolled up";
                else if (window.event.wheelDelta < 0) msge = "Wheel rolled down";
                else msge = "Not up or Down";

              document.getElementById("msge").value = msge;


<form id="frmEntry" name="frmEntry" method="post" action="_self" onmousewheel="getWheel();" size="3">
          <select id="country2" name="country2" tabindex="2">
          <option value="AFG">Afghanistan</option>
          <option value="ALB">Albania</option>
          <option value="DZA">Algeria</option>
          <option value="ASM">American Samoa</option>
          <option value="AND">Andorra</option>
          <option value="AGO">Angola</option>
          <option value="AIA">Anguilla</option>
          <option value="ATG">Antigua and Barbuda</option>
          <option value="ARG">Argentina</option>
          <option value="ARM">Armenia</option>
          <option value="ABW">Aruba</option>
          <option value="AUS">Australia</option>
          <option value="AUT">Austria</option>
          <option value="AZE">Azerbaijan</option>
          <option value="BHS">Bahamas</option>
          <option value="BHR">Bahrain</option>
          <option value="BGD">Bangladesh</option>
          <option value="BRB">Barbados</option>
          <option value="BLR">Belarus</option>
          <option value="BEL">Belgium</option>
          <option value="BLZ">Belize</option>
          <option value="BEN">Benin</option>
          <option value="BMU">Bermuda</option>
          <option value="BTN">Bhutan</option>
          <option value="BOL">Bolivia</option>
          <option value="BIH">Bosnia and Herzegovina</option>
        <input type="text" id="msge" size="15">

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.