【问题标题】:docking panel in xulxul 中的对接面板
【发布时间】:2011-07-14 10:41:21
【问题描述】:

如何在 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

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

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

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

【问题讨论】:

  • 您能否发布不起作用的完整示例。从你的描述看不清楚是什么问题。例如,我假设您在 XUL 文件中包含脚本文件,对吗?

标签: javascript xul docking


【解决方案1】:

我猜你的问题是你希望所有窗口共享 JavaScript 代码/状态/范围,无论你怎么称呼它;在“myWindow.xul”或“myPanel.xul”中加载的任何脚本中都没有定义“jsScriptFromOtherFile”,它是在调用window.open的父窗口中定义的。

每个“窗口”(或选项卡、iframe 等)都有自己的全局对象。要从不同的“窗口”访问变量,您首先必须获得该窗口的句柄。见Working with windows in chrome code

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-05
    相关资源
    最近更新 更多