FAQ Topic - How do I suppress a context menu (right-click menu)? (2012-02-22)

Discussion in 'Javascript' started by FAQ server, Feb 22, 2012.

  1. FAQ server

    FAQ server Guest

    -----------------------------------------------------------------------
    FAQ Topic - How do I suppress a context menu (right-click
    menu)?
    -----------------------------------------------------------------------

    A context menu, often triggered by right-click, can be requested by the
    user in a few ways. For example, on windows, shift + F10 and on macs,
    click-and-hold. Other input devices exist and mouse buttons can be
    configured, making the term "right click" a misnomer, in context.

    In browsers that allow it, a script can suppress the context menu by
    returning false from an object's `oncontextmenu` event handler.

    document.oncontextmenu = function() {
    return false;
    };

    Some browsers lack context menus (e.g. iphone). Browsers that have
    context menus do not always have a scriptable event for them. Some
    browsers can be configured to disallow scripts from detecting context
    menu events (IE, Opera); others may fire the event but be configured to
    disallow scripts from suppressing the context menu (Firefox,Seamonkey).

    Even when the context menu has been suppressed, it will still be
    possible to view/save the source code and to save images.

    <URL: http://en.wikipedia.org/wiki/Context_menu>
    <URL: http://kb.mozillazine.org/Ui.click_hold_context_menus>
    <URL: http://support.microsoft.com/kb/823057>
    <URL: http://stackoverflow.com/questions/1870880/opera-custom-context-menu-picking-up-the-right-click/1902730#1902730>
    <URL: http://support.mozilla.com/en-US/kb/Javascript#Advanced_JavaScript_settings>
    <URL: http://msdn.microsoft.com/en-us/library/ms536914%28VS.85%29.aspx>


    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, Feb 22, 2012
    #1
    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. =?Utf-8?B?QWJkYWxsYQ==?=

    Highlight text and right click for a custom context menu, asp

    =?Utf-8?B?QWJkYWxsYQ==?=, Mar 22, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    747
    Bruce Barker
    Mar 22, 2006
  2. hkaiser
    Replies:
    3
    Views:
    601
    Ebenezer
    Jan 13, 2012
  3. Leon
    Replies:
    3
    Views:
    197
    TaeHo Yoo
    Nov 26, 2004
  4. lcplben
    Replies:
    3
    Views:
    517
    Garrett Smith
    Oct 30, 2009
  5. FAQ server
    Replies:
    0
    Views:
    1,280
    FAQ server
    Feb 19, 2012
Loading...

Share This Page