Warning window in my Firefox addon

I am starting to develop firefox add-ons, so please excuse me if it is too dumb. I just couldn't find the answer here on Stack.

I try to launch a warning window from my addon:

alert('This is an alert'); 

However, it does not recognize the β€œwarning”. Which component should include (Require)?

Thanks!

+6
source share
2 answers

Maybe this can help you?

https://developer.mozilla.org/en-US/docs/XUL/School_tutorial/User_Notifications_and_Alerts?redirectlocale=en-US&redirectslug=XUL_School%2FUser_Notifications_and_Alerts

Since links sometimes die, I will save you scrolling and post the code that may be most useful:

 let alertsService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService); let title = this._bundle.getString("xulschoolhello.greeting.title"); let message = this._bundle.getString("xulschoolhello.greeting.label"); alertsService.showAlertNotification( "chrome://xulschoolhello/skin/hello-notification.png", title, message, true, "", this, "XULSchool Hello Message"); 
0
source

For a modal alert, as the question asks, it is better to use a request-request rather than alert-service:

 var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); prompts.alert(null, "AlertTitle", "AlertMessage"); 
+13
source

Source: https://habr.com/ru/post/951738/


All Articles