2011-10-19 48 views

回答

1

也可以通過創建面板並將其類型設置爲「箭頭」來完成此操作。實際上這是幾乎相同的例子,他們對panel.type reference page

這裏是如何做到這一點:

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

那麼你會打開它:

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

更多信息

+0

非常整齊!謝謝。 – mattsven

3

它可能在Firefox/XUL中,它也被稱爲door-hanger popuphttps://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);