简体   繁体   中英

How to set a favicon for an XUL window?

I open my Firefox extension window in a browser's tab. Is it possible to set a favicon for that tab?

Create this Folder structure inside the chrome folder

\\icons\\default

if your window id is mainwindow create a file named mainwindow.ico or mainwindow.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". 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. The problem was solved by adding the display property and setting it to "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. By creating files yourwindow.ico or yourwindow.xpm where yourwindow is the ID of your XUL window. And place the files in your directory structure like this : chrome/icons/default This will override the global icon files. More Information about XUL window and icon can be found here : https://developer.mozilla.org/en/XUL/window

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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