简体   繁体   中英

Display prompt with firefox addon sdk

Is it possible to display a blocking "yes no" confirm dialog to the user using chrome privileges?

Something like this:

在此处输入图片说明

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

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM