Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Disabling Control +w keybind

  • 6 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 wtfiwinomgs

more options

Could you add a option of closing tab with <kbd>Ctrl</kbd>+<kbd>w</kbd> to the advanced preference?

Also, I realized that:

```browser.tabs.warnOnClose False``` Does this option activates warn when closing the tab? If your answer is yes, it is not working at all.

Could you add a option of closing tab with <kbd>Ctrl</kbd>+<kbd>w</kbd> to the advanced preference? Also, I realized that: ```browser.tabs.warnOnClose False``` Does this option activates warn when closing the tab? If your answer is yes, it is not working at all.

所有回复 (6)

more options

Only closing a window (Ctrl+Shift+W) could possibly make Firefox display a warning, closing a tab is always done without a warning as you can reopen a closed tab via Ctrl+Shift+T.

You can possibly disable the key_close (Ctrl+W) and possibly also key_closeWindow (Ctrl+Shift+W) via an autoconfig.cfg file.

See:

more options

I'm not a js developer could you bear my nobleness? Because created these files but I think skipping something...

According to the this guide,I created two file ones named "autoconfig.js" under /usr/lib/firefox/defaults/pref

The content of the autoconfig.js is:

pref("general.config.filename", "firefox.cfg");                                 
pref("general.config.obscure_value", 0)                                         
                                                                                 
pref("key_close", 0)                                                            
pref("key_closeWindow", 0)                                                      
                                                                                 
unlockPref("pref.general.key_close")                                            
unlockPref("pref.general.key_closeWindow")  

Also provided EL with vim :set ff=unix


another is named firefox.cfg under /usr/lib/firefox/ then content

cat firefox.cfg // IMPORTANT: Start your code on the 2nd line

Also provided EL with vim :set ff=unix for so it's not working.

由maxemilian于修改

more options

You can use the autoconfig.cfg file in the Firefox installation folder to initialize (set/lock) preferences and run privileged JavaScript code.

To use Autoconfig, place two files into the Firefox installation directory.

  • on Windows and Linux, they go into the same directory where Firefox is installed
  • on macOS, they go into the Contents/Resources directory of the Firefox.app

The autoconfig.js file that specifies to use autoconfig.cfg is placed into the "defaults\pref" directory where the channel-prefs.js file is located. The autoconfig.cfg file is placed at the top level of the Firefox directory.

  • autoconfig.cfg and autoconfig.js need to start with a comment line (//)
  • autoconfig.js needs to use Unix line endings (LF instead of CR/LF)

See also:


The content of autoconfig.js:

//
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false);

The content of autoconfig.cfg:

let { classes: Cc, interfaces: Ci, manager: Cm  } = Components;
let Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
function ConfigJS() { Services.obs.addObserver(this, 'chrome-document-global-created', false); }
ConfigJS.prototype = {
  observe: function (aSubject) { aSubject.addEventListener('DOMContentLoaded', this, {once: true}); },
  handleEvent: function (aEvent) {
    let document = aEvent.originalTarget;
    let window = document.defaultView;
    let location = window.location;
    if (/^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i.test(location.href)) {
      if (window._gBrowser) {
        let keys = ["key_close","key_closeWindow"];
        for (var i=0; i < keys.length; i++) {
          let keyCommand = window.document.getElementById(keys[i]);
          if (keyCommand != undefined) { 
            keyCommand.removeAttribute("command"); 
            keyCommand.removeAttribute("key"); 
            keyCommand.removeAttribute("modifiers"); 
            keyCommand.removeAttribute("oncommand"); 
            keyCommand.removeAttribute("data-l10n-id"); 
          }
        }
      }
    }
  }
};
if (!Services.appinfo.inSafeMode) { new ConfigJS(); }

由cor-el于修改

more options

cor-el said

You can use the autoconfig.cfg file in the Firefox installation folder to initialize (set/lock) preferences and run privileged JavaScript code. To use Autoconfig, place two files into the Firefox installation directory.
  • on Windows and Linux, they go into the same directory where Firefox is installed
  • on macOS, they go into the Contents/Resources directory of the Firefox.app
The autoconfig.js file that specifies to use autoconfig.cfg is placed into the "defaults\pref" directory where the channel-prefs.js file is located. The autoconfig.cfg file is placed at the top level of the Firefox directory.
  • autoconfig.cfg and autoconfig.js need to start with a comment line (//)
  • autoconfig.js needs to use Unix line endings (LF instead of CR/LF)
See also:

The content of autoconfig.js:

//
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false);

The content of autoconfig.cfg:

let { classes: Cc, interfaces: Ci, manager: Cm  } = Components;
const {Services} = Components.utils.import('resource://gre/modules/Services.jsm');
function ConfigJS() { Services.obs.addObserver(this, 'chrome-document-global-created', false); }
ConfigJS.prototype = {
  observe: function (aSubject) { aSubject.addEventListener('DOMContentLoaded', this, {once: true}); },
  handleEvent: function (aEvent) {
    let document = aEvent.originalTarget;
    let window = document.defaultView;
    let location = window.location;
    if (/^(chrome:(?!\/\/(global\/content\/commonDialog|browser\/content\/webext-panels)\.x?html)|about:(?!blank))/i.test(location.href)) {
      if (window._gBrowser) {
        let keys = ["key_close","key_closeWindow"];
        for (var i=0; i < keys.length; i++) {
          let keyCommand = window.document.getElementById(keys[i]);
          if (keyCommand != undefined) { 
            keyCommand.removeAttribute("command"); 
            keyCommand.removeAttribute("key"); 
            keyCommand.removeAttribute("modifiers"); 
            keyCommand.removeAttribute("oncommand"); 
            keyCommand.removeAttribute("data-l10n-id"); 
          }
        }
      }
    }
  }
};
if (!Services.appinfo.inSafeMode) { new ConfigJS(); }

thank you very much for this, unfortunately unlike the OP I am looking for something entirely different.

jumping to tabs 1-9 with Ctrl + 1 through 9, how do I disable them? in his case, closing tab term is "key_close" but I am not sure the term for Ctrl + 1-9. Also, how can I go about adding "Ctrl + `" to previous tab rather than Ctrl + Shift + Tab?

please help, thank you.

more options

Hi wtfiwinomgs

That is about the key_selectTab (1-8) IDs and key_selectLastTab (9).

more options

cor-el said

Hi wtfiwinomgs That is about the key_selectTab (1-8) IDs and key_selectLastTab (9).

oh thank you. I did find the xhtml but it looked very confusing.

what about binding a new key to previous tab? as well as binding new key to undo previously closed tab?

in the script is to disable key but how do I bind them?