简体   繁体   English

如何为XUL窗口设置图标?

[英]How to set a favicon for an XUL window?

I open my Firefox extension window in a browser's tab. 我在浏览器的选项卡中打开我的Firefox扩展窗口。 Is it possible to set a favicon for that tab? 是否可以为该选项卡设置favicon?

Create this Folder structure inside the chrome folder 在chrome文件夹中创建此文件夹结构

\\icons\\default \\图标\\ DEFAULT

if your window id is mainwindow create a file named mainwindow.ico or mainwindow.xpm 如果您的窗口ID是mainwindow,则创建一个名为mainwindow.icomainwindow.xpm的文件

The code from the Mozilla site does not work correctly - it produces the following error message: "Warning: XUL box for box element contained an inline link child, forcing all its children to be wrapped in a block". Mozilla站点中的代码无法正常工作-它将产生以下错误消息:“警告:Box元素的XUL框包含一个内联链接子项,强制将其所有子项包装在一个块中”。 If this code is placed between 'window' tags it messes up all other controls on the window. 如果此代码放在“窗口”标记之间,则会混淆窗口上的所有其他控件。 If it is placed between 'box' tags, window controls are rendered fine, but still there is this error message. 如果它位于'box'标签之间,则窗口控件可以正常显示,但仍然存在此错误消息。 The problem was solved by adding the display property and setting it to "none". 通过添加display属性并将其设置为“none”解决了该问题。 The working code looks like this: 工作代码如下所示:

<window xmlns="mozilla.org/keymaster/gatekeeper/there.is.only.xul";
        xmlns:html="w3.org/1999/xhtml">
<!-- Icon from chrome -->
<html:link rel="icon" href="chrome://myExtension/content/path/to/favicon.png"
           style="display:none"/>

You can easily create an icon for a XUL window. 您可以轻松地为XUL窗口创建图标。 By creating files yourwindow.ico or yourwindow.xpm where yourwindow is the ID of your XUL window. 通过创建文件yourwindow.ico或yourwindow.xpm,其中你的窗口是你的XUL窗口的ID。 And place the files in your directory structure like this : chrome/icons/default This will override the global icon files. 并将文件放置在您的目录结构中,如下所示:chrome / icons / default这将覆盖全局图标文件。 More Information about XUL window and icon can be found here : https://developer.mozilla.org/en/XUL/window 有关XUL窗口和图标的更多信息,请访问: https//developer.mozilla.org/en/XUL/window

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM