繁体   English   中英

xul 中的对接面板

[英]docking panel in xul

如何在 xul 中制作对接面板。 它应该像在萤火虫中一样工作。 我试过这样的事情:

myWindow = window.open("chrome://project/content/myWindow.xul", "someRandomName", "chrome");

myWindow.xul 是:

<?xml version="1.0" encoding="utd-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<?xul-overlay href="chrome://project/content/myPanel.xul"?>

    <window id="dockedPanel" title="my super extension" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
        <hbox flex="1">
            <vbox id="myPanel"/>
        </hbox>
    </window>

myPanel.xul 是我的面板,myPanel 是 myPanel.xul 中 vbox 的 id

当我像这样打开 window 时,它看起来很像我想要的,但是所有按钮/其他组件都不起作用。 例如,如果我在 myPanel.xul 中有按钮:

<button id="myButton" label="button" onclick = "jsScriptFromOtherFile.someFunction()"/>

如果我单击 myWindow 上的该按钮,则不会调用 someFunction。 我不知道为什么,以及如何使它工作。

我想您的问题是您希望所有 windows 共享 JavaScript 代码/状态/范围,无论您如何称呼它; 'jsScriptFromOtherFile' 未在“myWindow.xul”或“myPanel.xul”中加载的任何脚本中定义,它在调用window.open的父 window 中定义。

每个“窗口”(或选项卡,iframe 等)都有自己的全局 object。 要从不同的“窗口”访问变量,您首先必须掌握 window。 请参阅使用镀铬代码中的 windows

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM