FAQ Topic - How do I disable the right mouse button? (2009-10-18)

Discussion in 'Javascript' started by FAQ server, Oct 18, 2009.

  1. FAQ server

    FAQ server Guest

    -----------------------------------------------------------------------
    FAQ Topic - How do I disable the right mouse button?
    -----------------------------------------------------------------------

    The nonstandard ` contextmenu ` event is not widely supported.
    Browsers that do support it may configured to prevent scripts from
    accessing that event.

    Example:

    <body oncontextmenu="return false">

    Disables the context menu where supported. Note that this will not
    prevent users from viewing your source code or copying images. To
    discourage copying, provide a copyright notice.

    http://msdn.microsoft.com/en-us/library/ms536914(VS.85).aspx

    https://developer.mozilla.org/En/DOM/Window.oncontextmenu


    The complete comp.lang.javascript FAQ is at
    http://jibbering.com/faq/

    --

    The sendings of these daily posts are proficiently hosted
    by http://www.pair.com.
     
    FAQ server, Oct 18, 2009
    #1
    1. Advertising

  2. FAQ server

    Stevo Guest

    FAQ server wrote:
    > -----------------------------------------------------------------------
    > FAQ Topic - How do I disable the right mouse button?
    > -----------------------------------------------------------------------


    Is there no room in the FAQ for a flippant (Pointed Ears style) answer?

    "Undo the screws at the bottom of your mouse and open it up, then cut
    the wires going to the right mouse button switch." :)
     
    Stevo, Oct 18, 2009
    #2
    1. Advertising

  3. FAQ server

    Evertjan. Guest

    Stevo wrote on 18 okt 2009 in comp.lang.javascript:

    > FAQ server wrote:
    >> -----------------------------------------------------------------------
    >> FAQ Topic - How do I disable the right mouse button?
    >> -----------------------------------------------------------------------

    >
    > Is there no room in the FAQ for a flippant (Pointed Ears style) answer?
    >
    > "Undo the screws at the bottom of your mouse and open it up, then cut
    > the wires going to the right mouse button switch." :)


    Warning:

    The right button could be the wrong button to disable, as you then are left
    with only the left one active, which could be the wrong one because if you
    turn the mouse by the usb or ps2 cable, the right button would be left, and
    with real wireless mice there are no wires to cut anyway.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Oct 18, 2009
    #3
  4. FAQ server

    Jorge Guest

    On Oct 18, 8:35 am, Stevo <> wrote:
    > FAQ server wrote:
    > > -----------------------------------------------------------------------
    > > FAQ Topic - How do I disable the right mouse button?
    > > -----------------------------------------------------------------------

    >
    > Is there no room in the FAQ for a flippant (Pointed Ears style) answer?
    >
    > "Undo the screws at the bottom of your mouse and open it up, then cut
    > the wires going to the right mouse button switch." :)


    Section 2: Which button is -exactly- the "right" one ?

    --
    Jorge.
     
    Jorge, Oct 18, 2009
    #4
  5. FAQ server

    rf Guest

    "Evertjan." <> wrote in message
    news:Xns9CA8711ED527Aeejj99@194.109.133.242...
    > Stevo wrote on 18 okt 2009 in comp.lang.javascript:


    > and with real wireless mice there are no wires to cut anyway.


    So then you simply cut the right wireless.
     
    rf, Oct 18, 2009
    #5
  6. Jorge wrote:
    > On Oct 18, 8:35 am, Stevo <> wrote:
    >> FAQ server wrote:
    >>> -----------------------------------------------------------------------
    >>> FAQ Topic - How do I disable the right mouse button?
    >>> -----------------------------------------------------------------------

    >> Is there no room in the FAQ for a flippant (Pointed Ears style) answer?
    >>
    >> "Undo the screws at the bottom of your mouse and open it up, then cut
    >> the wires going to the right mouse button switch." :)

    >
    > Section 2: Which button is -exactly- the "right" one ?
    >
    > --
    > Jorge.

    Its the one that isn't the wrong one.
     
    The Natural Philosopher, Oct 18, 2009
    #6
  7. rf wrote:
    > "Evertjan." <> wrote in message
    > news:Xns9CA8711ED527Aeejj99@194.109.133.242...
    >> Stevo wrote on 18 okt 2009 in comp.lang.javascript:

    >
    >> and with real wireless mice there are no wires to cut anyway.

    >
    > So then you simply cut the right wireless.
    >
    >

    no, you cut the PCB track. Or wedge a matchsick under the button.

    Or give them a one button macinstosh mouse.
     
    The Natural Philosopher, Oct 18, 2009
    #7
  8. FAQ server

    VK Guest

    On Oct 18, 1:49 pm, Jorge <> wrote:
    > On Oct 18, 8:35 am, Stevo <> wrote:
    >
    > > FAQ server wrote:
    > > > -----------------------------------------------------------------------
    > > > FAQ Topic - How do I disable the right mouse button?
    > > > -----------------------------------------------------------------------

    >
    > > Is there no room in the FAQ for a flippant (Pointed Ears style) answer?

    >
    > > "Undo the screws at the bottom of your mouse and open it up, then cut
    > > the wires going to the right mouse button switch." :)

    >
    > Section 2: Which button is -exactly- the "right" one ?


    "the context menu invoking button, the rightmost by default on the
    majority of mouse models" might be more accurate taking into account
    that the button functions can be easily swapped. The
    eventObject.button property is attached exactly to the current buttons
    *functionality*, not to their physical allocation left-to-right.

    Overall the FAQ topic is written "with a hate in it", so more
    accentuated on "don't do it!" rather than on "how to do it?". It has
    some historical logic behind it, because at the end of the last
    century, when the FAQ were made, one of most annoying questions were
    "How to prevent my page copied?" and "How to prevent my pictures
    saved?" etc. with 90% of context menu questions posed with it in mind.

    Now with the new stage of development of Web applications custom
    context menus support is a obvious must to any market-oriented
    browser, so respectively all of them support oncontextmenu handler.

    The main troublemaker is IE as usual. The first caveat is the shorten
    bubble retention period on IE (a prehistoric stability connected
    restriction no one bothered to remove ever since). This way
    <body oncontextmenu="return false;">
    will work on IE just fine (context menu locked) while
    <body oncontextmenu="return someFalseReturningFunction();">
    will be ignored by IE as the system will not hold the bubble for
    someFalseReturningFunction
    The second caveat is that while others (Gecko, Safari, Chrome) apply
    the handler to the window, IE applies it to document.body only and
    document.body doesn't necessary apply to the whole viewport.
    To overcome all this an universal solution could be like:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Demo</title>
    <meta http-equiv="Content-Type"
    content="text/html; charset=windows-1252">
    <style type="text/css">
    HTML {
    width: 100%;
    height: 100%;
    }
    BODY {
    width: 100%;
    height: 100%;
    }
    </style>
    <script type="text/javascript">

    function contextMenu(e) {
    if (e.button == 2) {
    // do context menu
    window.alert('Custom context menu');
    return false;
    }
    else {
    return true;
    }
    }
    </script>
    </head>
    <body
    oncontextmenu="return false;"
    onmouseup="return contextMenu(arguments[0] || event);">
    <p>click anywhere in this page</p>
    </body>
    </html>
     
    VK, Oct 18, 2009
    #8
  9. rf wrote:
    > "Evertjan." <> wrote in message
    > news:Xns9CA8711ED527Aeejj99@194.109.133.242...
    >> Stevo wrote on 18 okt 2009 in comp.lang.javascript:

    >
    >> and with real wireless mice there are no wires to cut anyway.

    >
    > So then you simply cut the right wireless.


    What about for trackpad or joystick? What about touch screen devices?

    What if the user activates a context menu by other means (shift +f10 in
    Opera).

    The presence of a mouse cannot be detected and should never be assumed.

    (and body modification should be mentioned in the FAQ)
    --
    Garrett
    comp.lang.javascript FAQ: http://jibbering.com/faq/
     
    Garrett Smith, Oct 20, 2009
    #9
  10. Jorge wrote:
    > On Oct 18, 8:35 am, Stevo <> wrote:
    >> FAQ server wrote:
    >>> -----------------------------------------------------------------------
    >>> FAQ Topic - How do I disable the right mouse button?
    >>> -----------------------------------------------------------------------

    >> Is there no room in the FAQ for a flippant (Pointed Ears style) answer?
    >>
    >> "Undo the screws at the bottom of your mouse and open it up, then cut
    >> the wires going to the right mouse button switch." :)

    >
    > Section 2: Which button is -exactly- the "right" one ?
    >

    That's right.
    --
    Garrett
    comp.lang.javascript FAQ: http://jibbering.com/faq/
     
    Garrett Smith, Oct 20, 2009
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. FAQ server
    Replies:
    0
    Views:
    84
    FAQ server
    Sep 9, 2006
  2. FAQ server
    Replies:
    0
    Views:
    101
    FAQ server
    Nov 6, 2006
  3. FAQ server
    Replies:
    18
    Views:
    153
    Dr J R Stockton
    Jun 28, 2009
  4. FAQ server
    Replies:
    0
    Views:
    70
    FAQ server
    Aug 22, 2009
  5. FAQ server
    Replies:
    2
    Views:
    67
    Garrett Smith
    Dec 18, 2009
Loading...

Share This Page