Reputation: 4688
Is it possible to display a blocking "yes no" confirm dialog to the user using chrome privileges?
Something like this:
Upvotes: 2
Views: 609
Reputation: 4688
I found the nsIPromptService, which does exactly what i want:
var chrome = require('chrome');
var prompts = chrome.Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(chrome.Ci.nsIPromptService);
var remove = prompts.confirm(null, 'title', 'message');
Upvotes: 1
Reputation: 37238
accept nicks answer but read this:
Here's another way to access nsIPromptService. And check that page for more alerts:
var {Cu, Ci} = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');
var doit = Services.prompt.confirm(null, 'title', 'message');
if (doit) {
//he clicked yes
}
instead of null you can pass in a window object like Services.wm.getMostRecentWindow(null)
and it becomes modal on that window
benefit of this way is it uses services.jsm so you arent loading nsipromptservice you're just getting a pointer to it, which is preferred way
Upvotes: 3