firefox - How to disable right click on certain websites

29
2014-01
  • Marc-Olivier Titeux

    I am not asking this question from a web developer but from an end-user.

    I am using several web sites (google drive, evernote and so on) that have context menu that activates upon a right click event. However, on my browser (Firefox), if I right click it opens my navigator context menu on top of the context menu implemented by the web developer(s) of the website. If I right click a second time, then the navigator context menu disapears, leaving space for the web app context menu.

    How can I, as an end-user, disable right clicks on specific websites? And if possible, I would like to have this possibility "on-demand", ie being able to reactivate right clicks when I want to.

    Is there an existing addon or a javascript tricks somewhere for this? And if not, which direction should I follow to code something like this?

  • Answers
  • Wladimir Palant

    I am not aware of any extensions to achieve this but creating one wouldn't be hard. You could use the Add-on SDK, most easy to be used via Add-on Builder that is a web application to create SDK-based extensions. The high-level SDK modules don't give you direct access to the browser window however, you have to use the largely undocumented window-utils module for that. The following code in main.js works:

    var icons = {
      "enabled": "http://www.mozilla.org/favicon.ico",
      "disabled": "http://www.mozilla.org/media/img/favicon.ico"
    };
    
    function disableContextMenu(event)
    {
      event.preventDefault();
    }
    
    require("widget").Widget({
      id: "disable-context-menu",
      label: "Disable Context Menu",
      contentURL: icons.enabled,
      onClick: function(view)
      {
        var window = require("window-utils").activeBrowserWindow;
        var menu = window.document.getElementById("contentAreaContextMenu");
        if (this.contentURL == icons.enabled)
        {
          menu.addEventListener("popupshowing", disableContextMenu, false);
          this.contentURL = icons.disabled;
        }
        else
        {
          menu.removeEventListener("popupshowing", disableContextMenu, false);
          this.contentURL = icons.enabled;
        }
      }
    });
    

    It's really as simple as that - adding this event handler to the context menu disables it, removing that event handler switches it back on. The extension also switches icons to indicate its state. That's it. Of course, if you want to keep the state per-tab then you will need a more elaborate logic. Good luck!

  • mvp

    Go to the Content tab under Tools > Options. Click on the Advanced... button next to the Enable JavaScript checkbox. This opens the Advanced JavaScript Settings dialog box. Toggle the checkbox option Disable or replace context menus in the list presented.


  • Related Question

    mouse - How to Disable Right-Click in Windows XP / Windows 7?
  • DuckMaestro

    What is the least invasive way (read: least amount of modification to the OS; or least invasive software or utility) to disable the right-click ability of a pointing device in Windows XP and/or Windows 7?

    Edit: apparently people are making silly assumptions and down-voting this question. To clarify on the backdrop -- this is for a Kiosk-like setup, not for personal use.


  • Related Answers
  • 8088

    I'm not sure if there is a simple way to do this across the whole OS (i.e. disable the button completely for every application) but you can at least disable the desktop/Explorer context menus.

    1. Browse to this key in the registry: HKEY_Current_User\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer

    2. Change the value of NoViewContextMenu to 1.

    If NoViewContextMenu doesn't exist then you can create it. Right click in the right-hand pane, select New, then DWORD Value (on Windows XP) or DWORD (32-bit) Value (on Windows 7).

  • rve

    I was looking for the same thing. I wanted to disable the right mouse button but I could not find a good software solution. I just physically removed the right mouse button from the circuitboard inside the mouse. It was the quickest and least invasive method I could find.

  • Bob

    I'm not sure about least invasive, but a simple Autohotkey script set to load on startup can do it.

    #NoTrayIcon
    RButton::Return
    

    You can also compile the script to a standalone executable so AHK does not have to be installed in the destination computer. Then it becomes a small, simple executable that you can run on startup to disable the right mouse button.

    You would also need to restrict access to Task Manager, so they can't just end the process.

  • HeekBoop

    I have read a few articles about disabling the right-click mouse function. They all seem to involve somewhat convoluted settings changes that yield limited results - the disabling takes place only in certain folders and programs. One respondent on a post provided a link to a downloadable disable program, but the file seems to have been removed from the site.

    I find it surprising and frustrating that this is not an optional setting in the Windows Control Panel.

    Might it be simpler to somehow mechanically disable the right side of the mouse itself? Could the cover of the mouse be removed, and whatever contact or button that triggers the right-click menu be removed or blocked off?