473,769 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cross browser mouse wheel event handler

cjl
Hey all:

I'm trying to write a cross-browser (IE and firefox) event handler for
the mousewheel. Basically my web app is an image viewer, so if you
scroll "down" with the wheel the next image should be displayed and if
you scroll "up" the previous image should be displayed.

So far I have:

function handleMouseWhee l(e)
{
if (!e) e = window.event;

if ( e.wheelDelta <= 0 || e.detail > 0) { changeImage(1); }
else { changeImage(-1); }
}

This code works in IE and in Firefox to the desired effect. The
problem I am having is with registering the event handler.

The following works for IE:
document.onmous ewheel = handleMouseWhee l;

And the following works for Firefox:
window.addEvent Listener("DOMMo useScroll", handleMouseWhee l, false);

But when I add the firefox event handler to my code, IE chokes with an
error "Object doesn't support this property or method".

What do I need to do to "hide" the firefox event handler code from IE?

-CJL

Oct 8 '05 #1
1 3695
cjl
Hmmm:
What do I need to do to "hide" the firefox event handler code from IE?


Looks like all I need to do is:

if (window.addEven tListener) {
window.addEvent Listener("DOMMo useScroll", handleMouseWhee l, false); }
else { document.onmous ewheel = handleMouseWhee l; }

Is this correct? Anyway, works for me.

-CJL

Oct 8 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
16028
by: Steve Belanger | last post by:
Has anybody heard or figured out a way to make a DIV with overflow: scroll to look the same in IE and Firefox in IE i have one table splitted in two, the bottom part is the scrolling (Set to a height of 100%), it displays properly.. But firefox hardly produce the scrollbars on that division, and instead makes the whole page to scroll. I know there is some incompatibility between the two browsers as far as following the CSS standards,...
6
6207
by: AccessWhiz | last post by:
I have been trying desperately for the past few days to figure out why the MouseWheel solution that I retrieved from the Lebans website won't work. The access database included with the solution responds to the the wheel regardless of the button. In my application I get an error message when I try to set the class. I'm hoping that I can get some help (cause I feel really stupid right now). Before we go too much further, I am using a...
1
1850
by: DotNetMania | last post by:
panel has not Key press event... that's why.. if i have to figure invoking any event out when panel clicked it is so difficult...what button is clicked .... button of Mouse like .. Left, Middle, and Right... how can i distiguish...
2
3363
by: Anders Eriksson | last post by:
Hello! I have a program with three views ------------------------------------ | | | | 1 | 2 | | | | | |--------------------------| | | |
13
2808
by: Nathan | last post by:
Hi, Can someone lead me to info on detecting and using the mouse button? All I can find in the MSDN docs is that you use e.Delta, but it doesn't explain in how. I tried detecting the roll of the wheel in the frm.MouseDown, but it didn't detect it. Thank for the help.
4
2733
by: ML | last post by:
I am trying to use the mouse wheel event on a numeric input box to allow the use to scroll to inc/dec the value by 1. The issue I am having is that the delta value returned seems to be off. From my understanding the delta is the number of detents the mouse has moved. The standard detent is supposedly 120 for one notch of the wheel, however when I turn the wheel 1 click I get 240. Is there someway to determine the actual detent setting...
0
1844
by: lechatthierry | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT BUTTON that open the Hyperlink in a new window for a Web application. I just want to capture the Shift click event and prevent it from opening a new page. Mouse Wheel didn't pose any problems but the other mouse buttons seems to ignore the...
2
3644
by: ingmar | last post by:
Hi, how do I register my Mouse wheel handler in my main VB .net 2005 form? My function Private Sub Me_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel never gets called. What do I need to do to tell VB that this function should handle the mouse wheel event?
1
1567
by: Alex Calder | last post by:
How's that for a subject line? :) OK, here's the deal. I have a web page that features a Flash movie about halfway down the page, and inside that Flash movie is content that typically exceeds the height of the movie, and accordingly, scrolls via use of a scroll bar. I've been testing out this page on friends, and the common complaint
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.