Notification Box messages. - Mozilla
This is a discussion on Notification Box messages. - Mozilla ; I am trying to add some text to the mozilla notification box. However I
am getting an exception when I try to retrieve the notification box:
var notificationBox = gBrowser.getNotificationBox():
gBrowser.getNotificationBox is not a function.
Does anyone know how to ...
-
Notification Box messages.
I am trying to add some text to the mozilla notification box. However I
am getting an exception when I try to retrieve the notification box:
var notificationBox = gBrowser.getNotificationBox():
gBrowser.getNotificationBox is not a function.
Does anyone know how to add a message to the notification box in the
current browser?
Thanks,Dave
-
Re: Notification Box messages.
Dave Drinkwater wrote:
> I am trying to add some text to the mozilla notification box. However I
> am getting an exception when I try to retrieve the notification box:
> var notificationBox = gBrowser.getNotificationBox():
> gBrowser.getNotificationBox is not a function.
Wow the documentation for this function seems very lame:
http://developer.mozilla.org/en/docs...otificationBox
Based on http://wiki.mozilla.org/XUL:NotificationBox
maybe you can look for the element by tag name.
Or from
http://code.google.com/p/scribefire/...gging.js?r=178
maybe from an element:
var nb = document.getElementById("content").getNotificationBox();
But another possibility is that your gBrowser is not in the state you
need, eg you are asking for stuff before the browser is fully loaded. If
you put javascript into script tags, generally top level code will run
too soon. You need to get your code to run onLoad or other events.
-
Re: Notification Box messages.
I found some sample code in the mozilla source that worked for me:
unfortunately we cannot access the notificationbox directly, because it
is computed on the fly (we think) but we can use the gBrowser object to
get it.
415 var notificationBox = gBrowser.getNotificationBox();
416 var notification =
notificationBox.getNotificationWithValue("popup-blocked");
417 if (notification) {
418 notification.label = message;
419 }
420 else {
421 var buttons = [{
422 label: popupButtonText,
423 accessKey: popupButtonAccesskey,
424 popup: "blockedPopupOptions",
425 callback: null
426 }];
427
428 const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
429 notificationBox.appendNotification(message, "popup-blocked",
430
"chrome://browser/skin/Info.png",
431 priority, buttons);
432 }
433 }
434 }
Thanks,
Dave
John J. Barton wrote:
> Dave Drinkwater wrote:
>> I am trying to add some text to the mozilla notification box. However
>> I am getting an exception when I try to retrieve the notification box:
>> var notificationBox = gBrowser.getNotificationBox():
>> gBrowser.getNotificationBox is not a function.
>
> Wow the documentation for this function seems very lame:
> http://developer.mozilla.org/en/docs...otificationBox
>
> Based on http://wiki.mozilla.org/XUL:NotificationBox
>
>
>
> maybe you can look for the element by tag name.
>
> Or from
> http://code.google.com/p/scribefire/...gging.js?r=178
>
> maybe from an element:
> var nb = document.getElementById("content").getNotificationBox();
>
> But another possibility is that your gBrowser is not in the state you
> need, eg you are asking for stuff before the browser is fully loaded. If
> you put javascript into script tags, generally top level code will run
> too soon. You need to get your code to run onLoad or other events.
-
Re: Notification Box messages.
Dave Drinkwater wrote:
> I found some sample code in the mozilla source that worked for me:
> unfortunately we cannot access the notificationbox directly, because it
> is computed on the fly (we think) but we can use the gBrowser object to
> get it.
>
> 415 var notificationBox = gBrowser.getNotificationBox();
? Your original post says this fails. Now it works?
-
Re: Notification Box messages.
John J. Barton wrote:
> Dave Drinkwater wrote:
>> I found some sample code in the mozilla source that worked for me:
>> unfortunately we cannot access the notificationbox directly, because
>> it is computed on the fly (we think) but we can use the gBrowser
>> object to get it.
>>
>> 415 var notificationBox = gBrowser.getNotificationBox();
>
> ? Your original post says this fails. Now it works?
Sorry for the confusion. I had to access the correct gBrowser in my
application. Apparently I was not in the beginning, also I was trying
to avoid using mozilla's functions calls. The above line does work, if
you use the correct gBrowser object.
Thanks,
Dave