javascript - xul 中的对接面板

标签 javascript xul docking

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

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是我的panel,myPanel是myPanel.xul中vbox的id

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

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

如果我在 myWindow 上单击该按钮,则不会调用 someFunction。我不知道为什么,也不知道如何让它发挥作用。

最佳答案

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

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

关于javascript - xul 中的对接面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6691924/

相关文章:

javascript - 在 VUE JS 的 Cursor 位置插入字符

c# - 用户控制停靠属性

windows - 从代码控制屏幕键盘位置上的 Windows 7

javascript - 为什么 Flux 中的单例 Store 会导致服务器端渲染出现问题

javascript - 有没有办法让这段代码更短

javascript - 在 div 中时使我的 Google map 响应

xul - 如何使用自定义相对路径为 xulrunner 应用程序设置配置文件目录?

java - 构建一个运行时动态的 GUI

javascript - 带有 FACEBOOK LIKE 按钮的 XUL IFRAME

delphi - TForm.ManualDock 应该调用 onFormShow 吗?