Javascript 无法使用userchrome.js在Firefox中禁用ctrl-w
我花了太多时间在linux中使用nano,现在我发现自己正试图在Firefox中使用control-w进行搜索。不幸的是,control-w在Firefox中映射到“close tab”,结果很不幸 我已经加载了userchromeJS加载项(这是Firefox的旧版本,userchromeJS可以使用),并告诉它加载chrome目录中的所有文件:Javascript 无法使用userchrome.js在Firefox中禁用ctrl-w,javascript,firefox,Javascript,Firefox,我花了太多时间在linux中使用nano,现在我发现自己正试图在Firefox中使用control-w进行搜索。不幸的是,control-w在Firefox中映射到“close tab”,结果很不幸 我已经加载了userchromeJS加载项(这是Firefox的旧版本,userchromeJS可以使用),并告诉它加载chrome目录中的所有文件: /* * userChromeJS * * This file can be used to customize the function
/*
* userChromeJS
*
* This file can be used to customize the functioning of Mozilla's user
* interface. Usage and syntax follow below; for useful code snippets see
* http://mozilla.zeniko.ch/userchrome.js.html.
*/
/*
* NOTE: userChromeJS includes an 'import' function to facilitate file management.
* An absolute path or relative path with Directory name property token can be
* used, as follows:
*
* // Single file (javascript .js or overlay .xul file)
* userChrome.import("Full file path");
* userChrome.import("Relative file path", "Token");
* // All .js and .xul files in a folder will be loaded.
* userChrome.import("Full file folder path");
* userChrome.import("Relative file folder path/name", "Token");
* userChrome.import("*", "Token");
*
* NOTE: absolute windows files and folders must be have backslash escaped:
* "C:\\Program Files\\Mozilla\\scripts\\myscript.js"
*
* Examples:
* // Import script in [ProfileDir]/chrome/scripts/myscript.js
* userChrome.import("scripts/myscript.js", "UChrm");
* // Import script in [Profiles]/scripts/myscript.js (share same script in
* // multiple profiles
* userChrome.import("scripts/myscript.js", "DefProfRt");
* // All .js or .xul in profile chrome directory
* userChrome.import("*", "UChrm");
* // Import overlay
* userChrome.import("C:\\Program Files\\Mozilla\\scripts\\myOverlay.xul");
* // Import everything in Desktop folder /scripts
* userChrome.import("scripts", "Desk");
* // Perhaps the only thing you need in this file.
* if (location == "chrome://browser/content/browser.xul") {
* userChrome.import("scripts", "DefProfRt");
* }
*/
/* Import all .js or .xul in profile chrome directory */
userChrome.import("*", "UChrm");
并在文件disable_ctrl_w.js中添加了对control-w的拦截,如下所示:
var kwa = document.getElementById('key_closeTab');
if (kwa) kwa.remove();
基于对control-q的拦截:
var kqa = document.getElementById('key_quitApplication');
if (kqa) kqa.remove();
我找不到使用userchrome.js禁用control-w的示例,但根据下面链接中的键定义,我相信key_closeTab是正确的名称
不幸的是,control-w仍在终止Firefox。Firefox篡改不是我的长裤;有人知道失败在哪里吗 这可能被视为密钥劫持。通常,不允许覆盖浏览器使用的密钥序列。这可能被视为密钥劫持。通常,不允许覆盖浏览器使用的键序列