问题
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