Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Javascript problem? right mouse click/context menu

56 views
Skip to first unread message

Frank Steiner

unread,
Apr 15, 2008, 5:16:38 PM4/15/08
to
Hi,

I'm running drupal on our website, a CMS for web servers. You edit all the
stuff in the browser. Works almost great with Opera, but there are some modules
like whe webfm module (if someone knows drupal ;-)) that define context
menus for some elements in the web page editor. I.e., you should right-click
on e.g. a link and get a drupal-specific context menu, done by Javascript,
instead of the normal Opera context menu for web pages.

Now this context menu works fine with IE and Firefox, but Opera just shows
its normal context menu (with Back, Forward, View Source, Bookmark page etc.)
instead of the javascript menu. These menus are essential and the webfm
module is unusable without those menus.

I have enabled the "receive right-mouse clicks" in the Javascript options,
but that doesn't change anything.

Anything known about this? Is that related with the fact that all those
"prevent right-mouse click to avoid image download from my webpage"
scripts don't work in Opera?

Is there any chance to make the right mouse key be passed to the script?
I thought "receive right-mouse clicks" option was exactly for that...

Doesn't work with 9.27 and 9.50, Windows and Linux.

cu,
Frank

--
Dipl.-Inform. Frank Steiner Web: http://www.bio.ifi.lmu.de/~steiner/
Lehrstuhl f. Bioinformatik Mail: http://www.bio.ifi.lmu.de/~steiner/m/
LMU, Amalienstr. 17 Phone: +49 89 2180-4049
80333 Muenchen, Germany Fax: +49 89 2180-99-4049
* Rekursion kann man erst verstehen, wenn man Rekursion verstanden hat. *

Frank Steiner

unread,
Apr 15, 2008, 5:25:04 PM4/15/08
to
Ok, here is a easy-to-test example:
http://www.dynamicdrive.com/dynamicindex1/contextmenu.htm

Gives a context menu when right-clicking anywhere in the page with Firefox,
but not with Opera (cited from a nice page about menu problems in Opera:
http://www.scss.com.au/family/andrew/opera/compatibility/menus/)

So is this a bug in Opera? Just looks like the right-click is not passed
to the script but still caught from Opera itself.

Rijk van Geijtenbeek

unread,
Apr 15, 2008, 8:46:30 PM4/15/08
to
Op Tue, 15 Apr 2008 23:16:38 +0200 schreef Frank Steiner
<fstein...@bio.ifi.lmu.de>:

..


> I have enabled the "receive right-mouse clicks" in the Javascript
> options,
> but that doesn't change anything.
>
> Anything known about this? Is that related with the fact that all those
> "prevent right-mouse click to avoid image download from my webpage"
> scripts don't work in Opera?

Opera doesn't support the javascript event 'oncontextmenu' which these
scripts use. Opera does support 'onrightclick', but as you see that is
disabled by default. I've been told in the past by our developers that
implementing support is not as trivial as making 'oncontextmenu' an alias
for 'onrightclick', the former apparently does a lot more.

--
Rijk van Geijtenbeek
Opera Software ASA, Documentation & QA
Tweak: http://my.opera.com/Rijk/blog/

"The most common way to get usability wrong is to listen to what users
say rather than actually watching what they do." - J.Nielsen

Frank Steiner

unread,
Apr 16, 2008, 3:08:17 AM4/16/08
to
Rijk van Geijtenbeek wrote

> Opera doesn't support the javascript event 'oncontextmenu' which these
> scripts use. Opera does support 'onrightclick', but as you see that is
> disabled by default. I've been told in the past by our developers that
> implementing support is not as trivial as making 'oncontextmenu' an alias
> for 'onrightclick', the former apparently does a lot more.

Thanks for that hint, I will try to work with it!

Frank Steiner

unread,
Apr 16, 2008, 7:51:13 AM4/16/08
to
Hmm, I didn't have any success with defining any action by document.onrightclick.

The only way I was able to trigger an event by the right mouse button was by
sth. like

addEventListener('mouseup',function(e){
if( e && e.button == 2 ){
document.write('a');
return false;
}
},true);

which writes an "a" to the screen when klicking the right mouse button.

Do you have a snippet how onrightclick is supposed to work?

Frank Steiner

unread,
Apr 17, 2008, 7:18:23 AM4/17/08
to
Diggin further into it, it seems that Opera allows the javascript
to receive right-clicks, but not to disable them.

E.g. sth. like

addEventListener( 'click', function(e){ e.stopPropagation();}, true );
:
:
<p onclick="alert('you clicked the p')">click to test</p>

will prevent the alert fot left mouse buttons, but not for right or
middle ones. I.e., whatever action you define for the right-mouse button,
you will get the context menu additionally.

Doesn't make sense, does it?

Frank Steiner

unread,
Apr 17, 2008, 9:51:53 AM4/17/08
to
I finally found a script working in Opera:
http://dev.fckeditor.net/attachment/ticket/11/Context%20tescase.htm

I've implemented it here: http://www.bio.ifi.lmu.de/~steiner/test.html

However, it works fine as long as we are at the top of the page. But
when press the down arrow key or pgdn once, then we get both, our own
context menu *and* the Opera context menu.

I guess event catching should not depend on the size of a page and if
we are on top or at the bottom. So this is bug, isn't it?

0 new messages