我有兴趣在 Firefox 窗口的右侧打开一个 webPanel。根据一篇 MDN 文章,我确定这可以通过设置浏览器元素的direction
样式来完成。但是,我希望在关闭 webPanel 后清除此设置。有没有办法可以检测到这一点?到目前为止,我能想到的唯一方法是轮询sidebarWindow.location.href
(检测侧边栏是否更改)和sidebarHidden
(检测侧边栏是否关闭)。
var browser = document.getElementById('browser');
browser.style.direction = "rtl";
var sidebarWindow = document.getElementById("sidebar").contentWindow;
var sidebarBox = document.getElementById('sidebar-box');
var sidebarHidden = sidebarBox.collapsed || sidebarBox.hidden;
sidebarWindow.addEventListener("unload", function (event) {
alert("1"); //This code fires when the web panel is opened
//but not when it is closed.
});
sidebarBox.addEventListener("unload", function (event) {
alert("2"); //This code does not fire.
});
sidebarWindow.addEventListener("close", function (event) {
alert("3"); //This code does not fire.
});
sidebarBox.addEventListener("close", function (event) {
alert("4"); //This code does not fire.
});
openWebPanel('Test', 'http://www.google.com');