Search code examples
javascriptfirefoxfirefox-addonfirefox-addon-sdk

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:

enter image description here


Solution

  • 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