472,338 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,338 software developers and data experts.

Cross browser mouse wheel event handler

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 handleMouseWheel(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.onmousewheel = handleMouseWheel;

And the following works for Firefox:
window.addEventListener("DOMMouseScroll", handleMouseWheel, 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?


Oct 8 '05 #1
1 3623
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.addEventListener) {
window.addEventListener("DOMMouseScroll", handleMouseWheel, false); }
else { document.onmousewheel = handleMouseWheel; }

Is this correct? Anyway, works for me.


Oct 8 '05 #2

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

Similar topics

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...
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....
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...
by: Anders Eriksson | last post by:
Hello! I have a program with three views ------------------------------------ | | | | 1 | 2 ...
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...
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...
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...
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...
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...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

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.