FF 扩展:带有动态菜单项的弹出窗口,每个菜单项都有另一个弹出窗口
我正在构建一个具有弹出窗口的扩展,每次鼠标悬停在弹出窗口选项上时,其元素都是由函数调用构造的。我能够实现这一目标。现在我需要为每个菜单项(在原始弹出窗口内)提供一个弹出窗口,但它不是动态的。我有这段代码,但它不起作用:
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);
但这不起作用。也就是说,弹出窗口(newitem)未打开。 有人可以帮我解决问题吗
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过 onpopupshowing 事件(https://developer.mozilla.org/en/XUL/menupopup#a-onpopupshowing)?
Have you tried the onpopupshowing event (https://developer.mozilla.org/en/XUL/menupopup#a-onpopupshowing)?