0
我已经使用Firefox插件SDK构建了以下代码,该插件在页面加载时成功向当前活动选项卡上的NotificationBox
添加通知。如何在Firefox页面加载时通知正确的选项卡?
如何将其更改为使用getNotificationBox()
方法的参数化版本,以便选择属于正在加载Document
的选项卡上的NotificationBox
?
const observer = require('observer-service');
var {Cc, Ci, Cr, Cu} = require('chrome');
observer.add('document-element-inserted', function(document) {
var window = document.defaultView;
var mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
var notificationBox = mainWindow.gBrowser.getNotificationBox();
notificationBox.appendNotification(
'This is my message',
'myNotifyId',
'chrome://global/skin/icons/information-16.png',
notificationBox.PRIORITY_INFO_LOW
);
});
很好。谢谢。 – Cheekysoft 2011-12-18 13:09:01