FF扩展:带有动态菜单项的弹出框,每个菜单项都有另一个弹出框 [英] FF extension: a popup with dynamic menuitems, with each menu item having another popup
问题描述
我正在构建一个具有弹出式窗口的扩展,每次将鼠标悬停在弹出选项上时,都会通过函数调用来构造元素。我能够做到这一点。现在我需要有一个弹出菜单项(在原来的弹出窗口),这是不是动态的。我有这个代码,但它不起作用:
pre $ var myMenuPopup = document.getElementById(file-popup4); (var m = 0; m
$ b $
newItem.setAttribute(label,publicdisplayname [m]);
newItem.setAttribute(id,public+ m);
var new1 = document.createElement(menuitem);
new1.setAttribute(label,Home);
new1.setAttribute(id,publichome+ m);
newItem.onclick = function(){
};
newItem.appendChild(new1);
myMenuPopup.appendChild(newItem);
但是这不起作用。也就是说,弹出窗口(newitem)没有打开。
有人可以帮我解决这个问题吗?解决方案
你有没有试过onpopupshowing事件(https:// developer.mozilla.org/zh/XUL/menupopup#a-onpopupshowing)?
I am building an extension that has a popup whose elements are constructed by a function call everytime the mouse hovers over the popup option. I am able to achieve this. Now I need to have a popup for each of the menu item (inside the original popup) which is not dynamic though. I have this code, but it does not work:
var myMenuPopup = document.getElementById("file-popup4");
for (var m=0; m<localpubliclist.length; m++)
{
var newItem = document.createElement("menupopup");
newItem.setAttribute("label", publicdisplayname[m]);
newItem.setAttribute("id", "public" + m);
var new1 = document.createElement("menuitem");
new1.setAttribute("label","Home");
new1.setAttribute("id", "publichome" + m);
newItem.onclick = function(){
};
newItem.appendChild(new1);
myMenuPopup.appendChild(newItem);
but this doesnt work. That is, the popup(newitem) does not open. Can someone please help me out with whats the problem
Have you tried the onpopupshowing event (https://developer.mozilla.org/en/XUL/menupopup#a-onpopupshowing)?
这篇关于FF扩展:带有动态菜单项的弹出框,每个菜单项都有另一个弹出框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!