从overlay.js 关闭xul 向导
在开发 Firefox 扩展时,我使用以下方法从overlay.js 创建一个向导窗口:
this.wizard = window.openDialog("chrome://firenow/content/wizard.xul", "","chrome, dialog, modal, resizable=no", params);
this.wizard.focus();
如何从overlay.js 关闭向导? 我应该调用它的 cancel()
函数,但我无法让它工作!
While developing a firefox extension, I create a wizard window from overlay.js using:
this.wizard = window.openDialog("chrome://firenow/content/wizard.xul", "","chrome, dialog, modal, resizable=no", params);
this.wizard.focus();
How can I close the wizard from overlay.js? I should call its cancel()
function but I can't get it working!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
this.wizard 将是一个 nsIDOMWindow 对象,但也实现了 nsIDOMWindowInternal 上的方法,因此您应该能够只调用 this.wizzard.close()
this.wizard would be a nsIDOMWindow object, but also implements the methods on nsIDOMWindowInternal, so you should be able to just call this.wizzard.close()
您以模态方式打开了向导,因此您的代码将停止运行,直到用户取消向导。 特别是,在向导关闭之前,您无法找到向导的窗口对象,此时聚焦它将不起作用! 如果您确实需要以模式方式打开向导,您仍然可以将其关闭,但您必须在向导本身中添加关闭向导的代码。
You opened the wizard modally so your code stops running until the user cancels the wizard. In particular you don't get to find out the window object of the wizard until after it is closed, at which point focusing it will have no effect! If you really need to open the wizard modally you might still be able to close it, but you would have to add the code that closes the wizard in the wizard itself.
您可以编写自己的隐藏函数来执行此操作。
如果你比较偏执,除了隐藏它之外,你还可以删除
wizard
的所有子节点。You can write your own hide function that does something to the extent of this.
If you're paranoid, you can also remove all the child nodes of
wizard
in addition to hiding it.