我正在尝试创建一个像这样的弹出窗口用于我的插件 - 这可能吗?如果是这样,它是如何完成的?
提前致谢!
最佳答案
这在 Firefox/XUL 中是可能的,它也被称为 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
比如这里的代码是弹窗通知带超时功能,不想要可以去掉超时功能。
超时功能的正常功能,如果用户点击浏览器上的任何地方,它会自动消失。
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);
关于javascript - 在 Firefox Addons 中创建这种弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7816749/