How to toggle sidebar in firefox
I want to toggle a sidebar on toolbar icon click. I define my toolbar in ff-sidebar.js file:
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", 开发者_JAVA百科shutdown, false);
Any idea how to do this? I can't find any reference.
I finally found a solution:
In my ff-overlay.xul
my sidebar is defined like this:
<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>
To toggle the sidebar just use the following command:
toggleSidebar("viewSidebar_smsflatrate");
精彩评论