我一直在尝试在firefox扩展程序中为门铃通知添加一个图标。然而,我无法实现这一目标。以下是我试过的......
PopupNotifications.show(gBrowser.selectedBrowser, "sample-popup",
message,
anchor, /* anchor ID */
{
label: primaryLabel,
accessKey: accessKey,
callback: function() {
alert("Doing something awesome!");
}
},
null, /* secondary action */
{
popupIconURL: WWWUP_ResourceURLs.icon
}
);
使用popupIconURL选项。以上不起作用,也不会产生错误。
我一直在查看文档https://developer.mozilla.org/en/Using_popup_notifications#Adding_an_icon_to_your_notification
中提到的方法我不明白将以下代码附加到...
.popup-notification-icon[popupid="sample-popup"] {
list-style-image: url("chrome://popupnotifications/skin/mozlogo.png");
}
一些指导意见将受到高度赞赏。
答案 0 :(得分:1)
此CSS代码必须应用于浏览器窗口。您可能有一个应用于浏览器窗口的叠加层,在此叠加层中添加以下行(documentation):
<?xml-stylesheet href="chrome://myExtension/skin/browser.css" type="text/css"?>
chrome://myExtension/skin/browser.css
指向包含以下内容的文件:
.popup-notification-icon[popupid="sample-popup"] {
list-style-image: url("popupIcon.png");
}
这会将chrome://myExtension/skin/popupIcon.png
设置为ID为"sample-popup"
的弹出式通知的图标。
如果您没有浏览器窗口覆盖,则可以使用chrome.manifest
文件中的style overlay获得相同的效果:
style chrome://browser/content/browser.xul chrome://myExtension/skin/browser.css