gpt4 book ai didi

javascript - xul 中的对接面板

转载 作者:行者123 更新时间:2023-11-30 06:46:05 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com