HI,
我正在尝试在安装后第一次重新启动 Firefox 后打开我的主页。
为此,我在加载页面上添加事件处理程序,并检查该事件第一次执行的位置。
window.addEventListener("load", initializeOverlay, false);
但我的问题是当firefox启动时如何在新选项卡中打开页面。我用
`window.open("https://www.xyz.com/");`
但这会在新窗口中打开页面,甚至可能在 Internet Explorer 中打开。
那么有什么方法可以在即将打开的同一窗口的新选项卡中打开页面。
谢谢
巴维克·戈亚尔
我设法使用首选项做类似的事情,而不是创建文件等。
/defaults/preferences/default.js 内部:
pref("extensions.extension_name.just_installed", true);
pref("extensions.extension_name.post_install_url", "http://www.google.com");
然后在附加组件的主 JS 文件中:
// Retrieve the preferences.
var prefs;
prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.extension_name.");
prefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
// If we just installed, open the post-install page and update the preferences.
var just_installed = prefs.getBoolPref("just_installed");
var post_install_url = prefs.getCharPref("post_install_url");
if (just_installed) {
prefs.setBoolPref("just_installed", false);
gBrowser.selectedTab = gBrowser.addTab(prefs.getCharPref("post_install_url"));
}
唯一的问题是,卸载扩展后,Firefox 不会重置该扩展保存的首选项。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)