简体   繁体   中英

Timeout problem in PopupNotification JavaScript XUL

This code working for me to display the door-hanger popup. But, when I want to use the time-out under the options it wont show up the pop-up notification.

Syntax:

Notification show(browser,id,message,anchorID,mainAction,secondaryActions,options);

My code:

PopupNotifications.show(gBrowser.selectedBrowser, "PDE-popup",
"Hi, there!, You can Build a PaDE by clicking on the PDE button!!",
null, /* anchor ID */
{
  label: "Build PDE",
  accessKey: "D",

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

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

  }
},null, { timeout: Date.now() + 10000,
                            persistWhileVisible: false });

1.What's wrong with this code? 2. How can I place this door hanger popup to be displayed on my tool bar button? This is the tool bar button

    <toolbarbutton id="pde-toolbar-button" label="Detect"/>

I want to disappear the pop-up notification in 10Seconds! Thank u guys.

I have no secondary options so, I made it null but the time-out is not functioning.

http://scenari-platform.org/svn/dev-core/trunk/Lib_XulRunner/Darwin/modules/PopupNotifications.jsm

https://developer.mozilla.org/en/JavaScript_code_modules/PopupNotifications.jsm#Notification_events

在此处输入图片说明

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*/
"PDES-popup", /*id*/
"Hi, there!, You can Build a PDE by clicking on the PDE button!!",/*message*/
null, /* anchor ID */
/* mainAction */
{
          label: "Build PDE",
          accessKey: "D",

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

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

          }
        },
null, /* secondaryActions*/

{ blablal:'options'}

);

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

The above code works fine, finally got a clear explanation from other forum for my problem.

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