如何在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是我的面板,myPanel是myPanel.xul中vbox的id
当我像这样打开窗口时,它看起来很像我想要的,但是所有的按钮/其他组件都不起作用。例如,如果我在myPanel.xul中有按钮:
<button id="myButton" label="button" onclick = "jsScriptFromOtherFile.someFunction()"/>如果我在myWindow上单击该按钮,则不会调用someFunction。我不知道为什么,以及如何让它工作。
发布于 2011-07-17 08:01:26
我猜你的问题是你期望所有的窗口共享JavaScript代码/状态/作用域,不管你怎么叫它;'jsScriptFromOtherFile‘没有在'myWindow.xul’或'myPanel.xul‘中加载的任何脚本中定义,它是在调用window.open的父窗口中定义的。
每个“窗口”(或选项卡、iframe等)获取它自己的全局对象。要从不同的“窗口”访问变量,首先必须获得该窗口的句柄。参见Working with windows in chrome code。
https://stackoverflow.com/questions/6691924
复制相似问题