如何在Firefox中关闭侧边栏 [英] How to close a sidebar in firefox
问题描述
pre $ unc:function(){
var sidebarWindow = document.getElementById(sidebar ).contentWindow;
if(sidebarWindow.location.href ==chrome://myaddon/content/mysidebar.xul){
//在边栏内容中操作
toggleSidebar('mySampleSidebar');
我将这个uninit称为window.unload事件:
window.addEventListener(unload,function(){myobj.uninit()},false);
<有人告诉我如何做到这一点,因为我试图做的是不工作。
感谢
Kapil
在load
事件侦听器函数。
请看这里例如:
$ p $ sidebar.onFirefoxLoad = function (event){
document.getElementById(contentAreaContextMenu)
.addEventListener(popupshowing,function(e)
{sidebar.showFirefoxContextMenu(e);},false);
toggleSidebar();
};
window.addEventListener(load,sidebar.onFirefoxLoad,false);
I have a sidebar inside my firefox addon. I want the following behavior for this sidebar - I should force close the sidebar if it is open when the browser is being closed (so that the next time the browser is opened the sidebar is not in an open state). I am trying to do this:
uninit: function() {
var sidebarWindow = document.getElementById("sidebar").contentWindow;
if (sidebarWindow.location.href == "chrome://myaddon/content/mysidebar.xul") {
// Act on the sidebar content
toggleSidebar('mySampleSidebar');
}
}
I call this uninit for the window.unload event:
window.addEventListener("unload", function() { myobj.uninit()}, false);
Can someone tell me how to achieve this, as what I am trying to do is not working.
Thanks Kapil
In your firefox sidebar overlay javascript add
toggleSidebar();
in the "load"
event listener function.
See here for example:
sidebar.onFirefoxLoad = function(event) {
document.getElementById("contentAreaContextMenu")
.addEventListener("popupshowing", function (e)
{ sidebar.showFirefoxContextMenu(e); }, false);
toggleSidebar();
};
window.addEventListener("load", sidebar.onFirefoxLoad, false);
这篇关于如何在Firefox中关闭侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!