PDA

View Full Version : Prevent middle click's default action?



jlizarraga
02-04-2009, 11:19 PM
Hi all,

Is there a way to prevent the default middle click action in IE7/8 or FF2/3?

I don't mind resorting to browser detection if that's the only way to do something with middle click - I'm just wondering if it's possible.

Even if the only thing I can do is use some proprietary IE stuff to give IE users a minor middle click enhancement, that's better than nothing.

Thanks!

jlizarraga
06-02-2010, 05:22 PM
Just stumbled across this old thread.

You *can* detect and respond to middle click in all browsers, assuming you don't mind browser sniffing (so it should be an enhancement, not part of normal functionality). This page helped me out:

http://unixpapa.com/js/testmouse.html

The trick to getting it to work for all browsers is to listen for the mousedown event rather than the click event (which doesn't always fire in IE for middle click).