简体   繁体   English

使用Firefox插件SDK显示提示

[英]Display prompt with firefox addon sdk

Is it possible to display a blocking "yes no" confirm dialog to the user using chrome privileges? 是否可以使用chrome权限向用户显示阻止的“是”确认对话框?

Something like this: 像这样:

在此处输入图片说明

accept nicks answer but read this: 接受缺刻的答案,但请阅读以下内容:

Here's another way to access nsIPromptService. 这是访问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 代替null,您可以传入诸如Services.wm.getMostRecentWindow(null)类的窗口对象,它在该窗口上变为模态

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 这种方式的好处是它使用services.jsm,因此您在加载nsipromptservice时只会得到指向它的指针,这是首选方式

I found the nsIPromptService , which does exactly what i want: 我找到了nsIPromptService ,正是我想要的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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