Firefox: right mouse button

M

Michael Schuerig

I'm trying to use the right mouse button to open a popup on a specific
element. The popup is triggered by a mouseup event. However, on
mousedown the standard context menu opens. To get around this, I listen
to that event, too, and stop it (preventDefault, stopPropagation). That
works on Konqueror (and presumably other KHTML-based browsers), but not
on Firefox. The latter still opens its context menu.

My search has turned up literally hundreds of blocker scripts for the
right mouse button. The few I've tested don't appear to work as
advertised with Firefox.

Now, my intention isn't to block my users from doing anything, rather
I'd like to offer them a form of interaction they're used to. In this
case the ability to access the settings of an object by right-clicking
it. Is it possible to make this work across browsers?

Michael
 
J

Janwillem Borleffs

Michael said:
I'm trying to use the right mouse button to open a popup on a specific
element. The popup is triggered by a mouseup event. However, on
mousedown the standard context menu opens. To get around this, I
listen to that event, too, and stop it (preventDefault,
stopPropagation). That works on Konqueror (and presumably other
KHTML-based browsers), but not on Firefox. The latter still opens its
context menu.

Use the oncontextmenu handler, which is supported by both FF and IE:

window.oncontextmenu = function () { return false; }


JW
 
M

Michael Schuerig

Janwillem said:
Use the oncontextmenu handler, which is supported by both FF and IE:

window.oncontextmenu = function () { return false; }

Thanks, that does it.

Michael
 
O

Owen

Michael Schuerig said:
I'm trying to use the right mouse button to open a popup on a specific
element. The popup is triggered by a mouseup event. However, on
mousedown the standard context menu opens. To get around this, I listen
to that event, too, and stop it (preventDefault, stopPropagation). That
works on Konqueror (and presumably other KHTML-based browsers), but not
on Firefox. The latter still opens its context menu.

My search has turned up literally hundreds of blocker scripts for the
right mouse button. The few I've tested don't appear to work as
advertised with Firefox.

Now, my intention isn't to block my users from doing anything, rather
I'd like to offer them a form of interaction they're used to. In this
case the ability to access the settings of an object by right-clicking
it. Is it possible to make this work across browsers?

Why are you trying to immitate desktop software behaviour in a web page?

Big mistake.

Remember web pages are basically just documents - trying to force them to
behave like 'real' software applications is a recipie for disaster.
Beleive me, I learned the hard way.

Either write software and do your right-clicking etc. there, OR write web
pages and accept that they're not designed to support those things.

Owen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top