Creating this kind of popup in Firefox Addons?

痴心易碎 提交于 2019-12-14 00:32:23

问题


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!


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/7816749/creating-this-kind-of-popup-in-firefox-addons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!