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

Detect if browser r-click context menu can be over-ridden

0 views
Skip to first unread message

Giles

unread,
Jul 21, 2008, 9:03:47 AM7/21/08
to
JS allows (right-click) custom context menus using
document.oncontextmenu=ShowMyContextMenu; . Some browsers (e.g. opera) don't
allow custom context menus, but do not throw an error if they are called -
it's just ignored.
Is there a way in script to test if a custom context menu is allowed (so if
not, an alternative can be offered, like a button with a drop-down list)?
Thanks, Giles


Old Pedant

unread,
Jul 22, 2008, 1:15:25 PM7/22/08
to
Couldn't you just set some page-scope JS variable during the setup of the
context menu and, if your other code doesn't detect that it was initialized,
do something else??


Giles

unread,
Jul 23, 2008, 8:31:26 AM7/23/08
to
"Old Pedant" wrote

I've since found that a (physical) right click in Opera does not send any
kind of message whatsoever that can be seen by JS. There is no way of
detecting when the user actually does a right-click (although simulating
right clicks is possible in code). So no point testing if a variable has
been initialised because you don't know if the user has even tried a right
click. Just because simulating it will initialise the variable doesn't mean
anything. I've given up on this, I don't think it is possible.

I have no objection to this behaviour for web pages, as one wants interface
consistency between web sites, and it is very annoying when the right click
is "stolen", but for creating stand-alone web applications rather than pages
it is a pain. The browsers should at least make it detectable whether custom
context menus are possible...


0 new messages