FAQ Topic - How do I disable the right mouse button? (2010-08-13)

D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
september.org>, Sat, 28 Aug 2010 14:16:05, Garrett Smith
Garrett said:
[...]
Any objections to that replacing the existing entry? Keep in mind that
the answer is already long, so additions to that should be brief.

No objection. It sounds like an improvement to me.
OK, I'll be uploading that either today or tomorrow (my time zone, that is).


Before assuming that there will be no further comment, you should ALWAYS
wait a couple of WORKING days. Usenet is not an instantaneous medium,
when you remember that other people have other things to do.
 
G

Garrett Smith

Before assuming that there will be no further comment, you should ALWAYS
wait a couple of WORKING days. Usenet is not an instantaneous medium,
when you remember that other people have other things to do.
Please see my other reply to you asking about providing explanation of
how `return false` prevents the default action of an event handler.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
september.org>, Sat, 28 Aug 2010 21:48:09, Garrett Smith
Can you explain why "suppress" is better here?

With sufficient experience of reading good English, it is reasonably
obvious. The word "prevent" is properly applied to events, not to
things.

"How do I prevent a context menu (right-click menu) appearing?" would be
satisfactory, but is longer than needed.

Returning false from most event handlers will prevent the default
action associated with the event. In a "contextmenu" event, the default
action is displaying a context menu.

Should the entry explain that? The concept is not specific to
contextmenu events and returning false is not the only way to prevent
the default action. For most events, eventArg.preventDefault() (W3C
Model)/window.event.returnValue = false (IE Model) will have the same
effect.

No : it should explain what I suggested, for the reasons given.

document.oncontextmenu = undefined ;

will do it; or a similar function returning true. (Tested, FF 3.0.19)
 
G

Garrett Smith

In comp.lang.javascript message<[email protected]
september.org>, Sat, 28 Aug 2010 21:48:09, Garrett Smith


With sufficient experience of reading good English, it is reasonably
obvious. The word "prevent" is properly applied to events, not to
things.

Is that it is confusing that trying to /prevent/ the user from
performing an action and /preventing/ the browser's default action
programmatically?

I'm not opposed to using suppress, but the W3C Events spec uses the term
"prevent" to describe the concept that you would call "suppressing" the
default action.

The W3C DOM event model has event.preventDefault().

That method is "used to signify that the event is to be canceled..." So
using the word "cancel" there, but then using the word "prevent" in the
method name and in context:

| ...the client may choose to prevent the DOM implementation from
| processing any default action associated with the event.

`return false` has the same effect when used with DOM 0 events -- that
is, it "prevents" the default action associated with the event.

"Suppress" should not be confusing. "Cancel" reads strange to me.
"How do I prevent a context menu (right-click menu) appearing?" would be
satisfactory, but is longer than needed.



No : it should explain what I suggested, for the reasons given.

document.oncontextmenu = undefined ;
It is a very bad idea to assign undefined to a host object property that
accepts a function. I suspect that IE6 will throw an error on that, as
it usually does.

will do it; or a similar function returning true. (Tested, FF 3.0.19)
It is not necessary to return true; just don't return false.
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
september.org>, Mon, 30 Aug 2010 17:44:18, Garrett Smith
Is that it is confusing that trying to /prevent/ the user from
performing an action and /preventing/ the browser's default action
programmatically?

I'm not opposed to using suppress, but the W3C Events spec uses the
term "prevent" to describe the concept that you would call
"suppressing" the default action.

The W3C DOM event model has event.preventDefault().

Method identifiers are not expected to be grammatical sentences,
especially when they are not sentences.

If one reads your first singly-quoted paragraph above, one can see that
you have difficulties with writing the language that Americans call
English.
That method is "used to signify that the event is to be canceled..." So
using the word "cancel" there, but then using the word "prevent" in the
method name and in context:

| ...the client may choose to prevent the DOM implementation from
| processing any default action associated with the event.

`return false` has the same effect when used with DOM 0 events -- that
is, it "prevents" the default action associated with the event.

"Suppress" should not be confusing. "Cancel" reads strange to me.

Cancel should only be used to undo a situation. In a confirm box, it
has the meaning of "Cancel asking for that" - though in general GUIs are
not a reliable guide to grammar.
It is a very bad idea to assign undefined to a host object property
that accepts a function. I suspect that IE6 will throw an error on
that, as it usually does.

It cannot be a very bad idea to assign the value which it had in the
first place, and in Firefox 3.0.19 it is initially undefined, of type
undefined. But other browsers may differ.
It is not necessary to return true; just don't return false.

In Firefox 3.0.19, it seems to be necessary to return a Boolean
expression of value false; other things that often pass as false are not
false enough here. If a function is used, it should be one returning a
Boolean expression; and therefore the example should shoe a Boolean.
 

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

Forum statistics

Threads
474,077
Messages
2,570,566
Members
47,202
Latest member
misc.

Latest Threads

Top