View Full Version : Help with the Firefox (FF) middle button click n drag issue

19 Oct 2006, 10:57 PM
Hey Jack,
Wow! What a site, man -- amazing library. I think we will be using a lot of your Yahoo UI extensions when we start redesigning this site I'm working on. Plenty of good, clean, cross-browser compatible, absolutely sweet ajax-ness. Very cool.
The reason I'm writing is because, in between now and when we actually start work on that site, it has a really aggravating bug, and that is if you use the middle button to click on some of our absolutely positioned images (they are positioned on top of another image), it starts to scroll the whole page in a rather strange, bizarre, annoying way. Of course, it only happens in Firefox -- IE and Safari handle it correctly. Correctly, in this context is to behave like the middle-button-click and drag behaves everywhere on your site. That is, it doesn't do anything. Google maps has a similar setup and have effectively fixed it - somehow.

So the question is, how do you turn off this annoying autoscroll behavior, in JS/DHTML. Do you even understand what I'm talking about?

For any help you could offer, I would be most grateful,

Thanks again,


20 Oct 2006, 3:39 AM
This is untested but should give you the idea:

YAHOO.ext.EventManager.mon(document.body, 'mousedown', function(e){
if(e.browserEvent.which == 2 && !e.findTarget(null, 'a')){
e.preventDefault(); // may need e.stopEvent()

'which' is mozilla specific and 2 is the middle button. The findTarget code allows for middle clicking links to still work.

Are you having this problem with a yui-ext component or is it random?

21 Oct 2006, 1:20 AM
Thanks very much!

I will definitely be giving this a try on Monday. I think the e.preventDefault() is what we are missing.

It is currently on a component unrelated to yui -- I just noticed while browsing for possible libraries to use on our upcoming redesign that you had circumvented this annoying bug (and that you actually responded to questions on your forum).

Many thanks again,


PS Hope this forum gets indexed by Google! I couldn't find this problem mentioned anywhere!