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...