在 Firefox Addons 中创建这种弹出窗口?

发布于 2024-12-11 06:04:58 字数 136 浏览 0 评论 0原文

在此处输入图像描述

我正在尝试创建一个像这样的弹出窗口以在我的插件中使用 - 这可能吗?如果是的话,是怎么做到的?

提前致谢!

enter image description here

I'm trying to create a popup like this for use in my addon - is it possible? If so, how's it done?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风追烟花雨 2024-12-18 06:04:58

在 Firefox/XUL 中是可能的,它也被称为door-hanger popup
https://developer.mozilla.org/en/JavaScript_code_modules/PopupNotifications.jsm#Notification_events
http://scenari-platform.org/svn /dev-core/trunk/Lib_XulRunner/Darwin/modules/PopupNotifications.jsm

例如,这里的代码是带有超时功能的弹出通知,如果您不想,可以删除超时功能。

超时功能和超时功能的正常功能如果用户单击浏览器上的任何位置,它就会自动消失。

Components.utils.import('resource://app/modules/PopupNotifications.jsm');
var notify  = new PopupNotifications(gBrowser,
                                       document.getElementById("notification-popup"),
                                       document.getElementById("notification-popup-box"));

var notification =  notify.show(
gBrowser.selectedBrowser,  /*browser*/
"Extension-popup", /*id*/
"Hi, there!, I got a message for you!!",/*message*/
null, /* anchor ID */
/* mainAction */
{
          label: "Build PDE",
          accessKey: "D",

          callback: function() {
                      if(nodeSRC!=null) pde.emptyNodeSRC(nodeSRC);

              window.openDialog("chrome://myextension/content/mypage.xul", "hello", "chrome,width=400,height=360",userContent, nodeSRC);

          }
        },
null, /* secondaryActions*/

{ blablal:'options'}

);

setTimeout(function(){
notification.remove();
}, 900);

It's possible in Firefox/XUL, it's also called as door-hanger popup.
https://developer.mozilla.org/en/JavaScript_code_modules/PopupNotifications.jsm#Notification_events
http://scenari-platform.org/svn/dev-core/trunk/Lib_XulRunner/Darwin/modules/PopupNotifications.jsm

For example, the code here is popup notification with time out function, if you dont want you can remove the time out function.

The normal functionality of the time out function & it will disappear automatically if the user clicks any where on the browser.

Components.utils.import('resource://app/modules/PopupNotifications.jsm');
var notify  = new PopupNotifications(gBrowser,
                                       document.getElementById("notification-popup"),
                                       document.getElementById("notification-popup-box"));

var notification =  notify.show(
gBrowser.selectedBrowser,  /*browser*/
"Extension-popup", /*id*/
"Hi, there!, I got a message for you!!",/*message*/
null, /* anchor ID */
/* mainAction */
{
          label: "Build PDE",
          accessKey: "D",

          callback: function() {
                      if(nodeSRC!=null) pde.emptyNodeSRC(nodeSRC);

              window.openDialog("chrome://myextension/content/mypage.xul", "hello", "chrome,width=400,height=360",userContent, nodeSRC);

          }
        },
null, /* secondaryActions*/

{ blablal:'options'}

);

setTimeout(function(){
notification.remove();
}, 900);
捶死心动 2024-12-18 06:04:58

也可以通过创建面板并将其类型设置为“箭头”来完成此操作。事实上,这与他们在 panel.type 上的示例几乎相同参考页面

以下是操作方法:

<panel id="testPanel" type="arrow">
    <vbox>
        (... content goes here ...)
    </vbox>
</panel>

然后您可以使用以下命令打开它:

panel.openPopup(elementThatShouldTriggerIt, "before_start", 0, 0, false, false);

有关MDN.Panel

It is also possible to do this by creating a panel and setting it's type to "arrow". In fact that's almost the same example that they have on the panel.type reference page:

Here's how to do it:

<panel id="testPanel" type="arrow">
    <vbox>
        (... content goes here ...)
    </vbox>
</panel>

Then you would open it with:

panel.openPopup(elementThatShouldTriggerIt, "before_start", 0, 0, false, false);

More information on MDN.Panel

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文