2011-09-13 7 views
1

이 코드는 도어 행거 팝업을 표시하는 데 적합합니다. 그러나 옵션 아래에서 시간 제한을 사용하려면 팝업 알림이 표시되지 않습니다.PopupNotification의 시간 초과 문제 JavaScript XUL

구문 :

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

내 코드 :

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의 잘못이 코드? 2. 도구 모음 버튼에이 문 행어 팝업을 표시하려면 어떻게합니까? 이 도구 모음 버튼

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

내가 10 초에 팝업 알림을 사라지게 할 것입니다! 고마워.

보조 옵션이 없으므로 null로 설정했지만 시간 제한이 작동하지 않습니다.

enter image description here

답변

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

위의 코드는 잘 작동

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

는 결국 내 문제에 대한 다른 포럼에서 명확한 설명을 얻었다.