我想在工具栏图标点击上切换侧边栏。我在ff-sidebar.js文件中定义了我的工具栏:
var mainWindow = null;
function startup() {
mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
// Sidebar is loaded and mainwindow is ready
}
function shutdown() {
// Sidebar is unloading
}
window.addEventListener("load", startup, false);
window.addEventListener("unload", shutdown, false);
知道怎么做吗?我找不到任何参考。
答案 0 :(得分:0)
我终于找到了解决方案:
在我的ff-overlay.xul
我的侧边栏中定义如下:
<broadcasterset id="mainBroadcasterSet">
<broadcaster id="viewSidebar_smsflatrate"
label="&smsflatrateSidebar.label;"
autoCheck="false"
type="checkbox"
group="sidebar"
sidebarurl="chrome://smsflatrate/content/ff-sidebar.xul"
sidebartitle="&smsflatrateSidebar.label;"
oncommand="toggleSidebar('viewSidebar_smsflatrate');" />
</broadcasterset>
要切换侧边栏,只需使用以下命令:
toggleSidebar("viewSidebar_smsflatrate");